Is the objectAtIndex start with 1 instead of 0? I use the objectAtIndex , and passing data 0, but it said that this is out of bound. So, I guess that is start at 1, am I right?
It starts at 0. If you got an exception, it's because the array was empty. You have to add something to the array first before it has any contents. Use addObject:
to put items into it. Use count
to find out how many items are currently in it.
NSMutableArray is zero-indexed. However; from the docs:
If index is beyond the end of the array (that is, if index is greater than or equal to the value returned by count), an NSRangeException is raised.
If there is nothing stored in the array, accessing index 0 will fail the above test, and cause the error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With