Re: NSCFArray beyond bounds
Re: NSCFArray beyond bounds
- Subject: Re: NSCFArray beyond bounds
- From: "Alan Smith" <email@hidden>
- Date: Fri, 29 Dec 2006 11:02:59 -0500
I've had this happen to me a lot as well. The easiest way is to look
for calls to objectAtIndex that doesn't use a constant. For example: a
loop that calls objectAtIndex using the iteration number. It may also
be that you're trying to access an object that has been removed from
the array and you didn't realize.
As a general rule it is a good idea to have some error checking when
calling objectAtIndex.
if ([array count] > index)
{
object = [array objectAtIndex: index];
}
else
{
NSLog(@"Bummer, we've messed up somehow. The array is too short,
index (%i) is out of bounds", index);
}
Good luck hunting the bug down.
Peace, Alan
--
// Quotes from yours truly -------------------------
"You don't forget, you just don't remember."
"Maturity resides in the mind."
"Silence is the Universe's greatest gift."
"When the World realizes that religion really is unnecessary, then it
shall evolve."
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden