• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSCFArray beyond bounds
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >NSCFArray beyond bounds (From: Alexander Cohen <email@hidden>)

  • Prev by Date: Re: NSCFArray beyond bounds
  • Next by Date: Registering as FrameLoadDelegate for a WebView
  • Previous by thread: Re: NSCFArray beyond bounds
  • Next by thread: Registering as FrameLoadDelegate for a WebView
  • Index(es):
    • Date
    • Thread