I have created an app which has a library of images. I have imported the images in to my resources folder in Xcode and am currently loading them in to an array in the appDelegate when the app loads. This is happening each time. I am now worried that as the library grows the app will run out of memory. Is there a better way of loading these?
the structure is
Library > category > image list > image
I have an NSMutableArray called mainLibrary
which I then add another nsmutablearray for each category. For example
NSMutableArray *arrHome = [[NSMutableArray alloc] initWithObjects: @"Home",
[NSDictionary dictionaryWithObjectsAndKeys: [NSString stringWithFormat:@"%@/%@", resourcePath, @"alarm_clock.png"], @"image_path", @"Alarm Clock", @"title", nil],
[NSDictionary dictionaryWithObjectsAndKeys: [NSString stringWithFormat:@"%@/%@", resourcePath, @"bathtub.png"], @"image_path",@"Bathtub", @"title", nil],
nil];
[mainLibrary addObject: arrHome];
The above is for the "home" category and contains only two images. For other categories, I have the NSDictionary line for each image - there can be up to 100 images in each category.
If I am loading in 50mb+ of images to an array will this cause the app to become unresponsive - or more than likely, simply crash as it uses more of the 24mb (ish) allowance per app??
I am wondering whether I should do the above code and read in to the array ONCE a category has been selected - but that might then cause it to stall for the user.
Any thoughts?!
ps) I also need to have a think about Retina display. With 600+ images, duplicating them would mean my binary size would rocket!!