Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem with NSMutableArray arrayWithObjects:

NSMutableArray *images = [NSMutableArray arrayWithObjects:[UIImage imageNamed:@"JGirl 01.jpg"],
    [UIImage imageNamed:@"JGirl 03.jpg"], ... ,
    [UIImage imageNamed:@"JGirl 48.jpg"],
    nil];

self.view = [[[SlideShowView alloc] initWithImages:images byIndex:index] autorelease];

assume that my images contain 48 object but when i debug images have only 23 objects.

Why aren't all my images loading?

like image 865
RAGOpoR Avatar asked Nov 21 '25 02:11

RAGOpoR


1 Answers

Sounds like a problem with nil-termination. If one of your image objects (the 24th, probably) is coming back nil because of a typo in the name or a corrupt/non-existent image file, it will act like the final "nil" that terminates the list and your array will ignore everything after that. It's a common pitfall with arrayWithObjects: and dictionaryWithObjectsAndKeys:

like image 143
Kenny Winker Avatar answered Nov 22 '25 17:11

Kenny Winker



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!