Shishir.bobby
Shishir.bobby

Reputation: 10984

NSRangeException with NSArray objectAtIndex, index beyond bounds

Can anyone let me know what the following error means in iOS Objective-C:

Terminating app due to uncaught exception 'NSRangeException', reason: '-[NSCFArray objectAtIndex:]: index (13) beyond bounds (13)'

Upvotes: 2

Views: 5939

Answers (1)

Jason Coco
Jason Coco

Reputation: 78353

It means that your index is not within the valid range for your array. Your array has 13 elements and you are trying to access the 14th element. In C, indexes start at 0, so arrays have indexes that are valid from 0 to length - 1.

This is typically caused by an off by one error.

Upvotes: 7

Related Questions