Where would be the best practice to store dozens, possibly hundreds of png images that should come bundled in an iphone app?
Will there be a way to access them with UIImagePickerController or would I have to create some other method of doing that myself?
Also, what is best practice in terms of bundling them? In-App bundling or having the app download them from server?
If you need the images to be available offline, I would put it in your app bundle. I would create a physical folder and drag it into the Xcode project and chose create folder reference which should show up as blue color folder icon. Put all your png files in that folder.
To get the listing of all files in that folder:
NSString *filesPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"pngfolder"]; // where pngfolder is the folder as described above.
NSArray *filesList = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:filesPath error:nil];
To read an individual image file at index i for example in the filesList array above:
NSString *sourcePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:[filesList objectAtIndex:i]];
UIImage *img = [[UIImage alloc]initWithContentsOfFile:sourcePath];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With