Reputation: 473
This seems like a basic question.. but my array size is 64 and I am replacing an object at index 63. Like this:
[myMutableArray replaceObjectAtIndex:myIndex withObject:myObj];
So I have no idea why gdb is telling me this:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSCFArray objectAtIndex:]: index (64) beyond bounds (64)'
Why is it saying my index is 64? I'm passing in 63.
Thanks.
Upvotes: 0
Views: 6185
Reputation: 57188
Try NSLog'ing the value of myIndex just before the call, or looking for other places that could be causing this exception.
Try setting an "Exception breakpoint" in Xcode (this is equivalent to breaking on -[NSException raise]
and/or objc_exception_throw
) to see where it's coming from. (See here about exception breakpoints.)
Upvotes: 10