I\'ve adding a series of folders to my project (using the Add existing file option). This results in the folder contents being shown in Xcode as a blue folder.
The follo
To access and store files on the iPhone I recommend reading this.
Erica Sadun has also written a nice shorty about accessing file within a app bundle.
Note that how files are organized in Xcode does not show how they will end up in the app bundle. The best way is to select the app bundle in the Finder and CTRL-click and select Show Package Content.
The problem with your imageWithContentsOfFile code is that you're assuming that /
is the root of the bundle, when it's the root of the FS!
So, pathForResource:ofType:inDirectory:
is probably the easiest way to get the path you need.
Otherwise, you can get the root of the bundle and prefix that to your paths.
Okay, I figured out one way in code to get what I needed:
NSString *dir = [NSString stringWithFormat:@"File-03/images", imageIndex];
NSString *file = [NSString stringWithFormat:@"image-%02d", imageIndex];
NSString *path = [[NSBundle mainBundle] pathForResource:file ofType:@"jpg" inDirectory:dir];
return = [UIImage imageWithContentsOfFile:path];
The trick was to inDirectory in the bundle call.