I am doing lazy loading images into an array when the application has loaded. I tried using NSMutableArray and NSArray (I don't need to modify the array after creating it), but the latter falls on me.
...
[self performSelectorInBackground:@selector(loadImageArrays) withObject:nil];
...
- (void)loadImageArrays {
NSAutoreleasePool *pool;
pool = [[NSAutoreleasePool alloc] init];
NSString *fileName;
imageArray = [[NSMutableArray alloc] init];
for(int i = 0; i <= x; i++) {
fileName = [NSString stringWithFormat:@"image_0000%d.png", i];
[imageArray addObject:[UIImage imageNamed:fileName]];
}
[pool drain];
}
vs
NSAutoreleasePool *pool;
pool = [[NSAutoreleasePool alloc] init];
imageArray = [[NSArray alloc] initWithObjects:
[UIImage imageNamed:@"image_00000.png"],
[UIImage imageNamed:@"image_00001.png"],
[UIImage imageNamed:@"image_0000X.png"],
nil];
[pool drain];
NSZombieEnabled = YES tells me that [UIImage save] was sent to the freed instance when using the last code snippet. Both arrays have a (non-atomic, persistent) property in my h file. Why are images not saved by NSArray?
source
share