I have an array i'm filling with images with a loop
items开发者_运维技巧 = [[NSMutableArray alloc] init];
for (int i=0; i<43; i++) {
NSString *filepath = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"%d",i] ofType:@"png"];
UIImage *image = (UIImage*)[UIImage imageWithContentsOfFile:filepath];
[items addObject:image];
}
it works as long as I set the max amount to match my test images. (in this case 43) if I set the max to a higher number, say 200 it of course crashes cause its trying to add nil objects to the array.
How would I go about being able to add the random number of images with that naming scheme to that array?
I have heard mention of using NSFileManager to add the files to array, is that the better method?
精彩评论