Testing for contents of an NSArray without risking range error

Posted by Dan Ray on Stack Overflow See other posts from Stack Overflow or by Dan Ray
Published on 2010-05-24T19:16:54Z Indexed on 2010/05/24 19:21 UTC
Read the original article Hit count: 239

Filed under:
|

I'm foolishly saying:

if ([imageCache objectAtIndex:index]) {

Problem is, on my first time through this, I haven't put ANYTHING in my NSMutableArray *imageCache, and this croaks with a range error.

How can I ask an NSMutableArray whether it has anything for a particular index?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c