I am currently building an application that generates images and stores them in an NSMutableArray, which then used in a UINavigation (Cell.imageView.image). I need to be able to handle up to 2000 images without causing lag in my application.
Currently how I set this generating is by calling the generating method when cellForRowAtIndexPath
is accessed. Which seems to cause a 4-5 second lag before the next navigation is called.
fortunately after those 4-5 seconds the generating is done and there is no issues.
In the world of iProducts waiting 4-5 seconds isn't really an option. I am wondering what my options are for generating these images in the background. I tried using threads [self performSelectorInBackground:@selector(presetSnapshots) withObject:nil]
;
but that only gave me issues about vectors for some reason.
Heres the generating code:
-(void)presetSnapshots{
//NSAutoreleasePool* autoReleasePool = [[NSAutoreleasePool alloc] init];
for (int i = 0; i < [selectedPresets count]; ++i){
GraphInfo* graphInfo = [selectedPresets objectAtIndex:i];
graphInfo.snapshot = [avc takePictureOfGraphInfo:graphInfo PreserveCurrentGraph:false];
[graphInfo.snapshot retain];
}
//[autoReleasePool drain];
presetSnapshotFinished = YES;
}
inside - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
is
if (presetSnapshotFinished == NO){
[self presetSnapshots];
//[self performSelectorInBackground:@selector(presetSnapshots) withObject:nil];
}
cell.imageView.image = [[selectedPresets objectAtIndex:indexPath.row] snapshot];
Edit:
I also rather not use coreData for this. The images are 23x23 and coming out to about 7kb. So its about 6MB being use at any giving time in memory.