Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best place to 'bundle' your application images in iPhone app

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?

like image 292
thedude Avatar asked Dec 28 '25 20:12

thedude


1 Answers

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];
like image 92
user523234 Avatar answered Dec 31 '25 12:12

user523234