What is the Max length of a resource name?
In my XCode project, I added a Sounds folder to my Resources folder. Into the Sounds folder, I dropped a couple of MP3 files with fairly long names (25-30 chars). I like to be descriptive. However, t开发者_JS百科he following code chokes with an UNCAUGHT EXCEPTION:
fileURL = [[NSURL alloc] initFileURLWithPath:[mainBundle pathForResource:@"really_really_long_name_for_real" ofType:@"mp3"]];
If I change the name of the resource to "blah.mp3" and the corresponding code line to:
fileURL = [[NSURL alloc] initFileURLWithPath:[mainBundle pathForResource:@"blah" ofType:@"mp3"]];
everything works fine.
Is there a max length for a name of a resource?
I'm not sure if the same is true on the iPhone as the Mac, but on the Mac files are limited not by the file name, but by the full path length (1024 bytes, IIRC).
(At least, this was true on Leopard. I haven't tried this on 10.6+)
I don't think there is such type of limitation on resource names because in my current project I am saving images to the documents folder which are named by concatenating more than 7 to 8 words which makes my name around 60-70 characters long, and everything is working fine for me. So I think the problem would the use of special characters you have used in naming your files. So just check for these special characters.
Thanks,
Madhup
The maximum length of a resource name is 255 characters.
精彩评论