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?
+1
A:
No, it starts with 0.
Make sure your array is populated though. If the array is empty, you can't use -objectAtIndex:
with any indices, since there's no way to return something.
KennyTM
2010-04-14 13:44:25
+4
A:
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.
quixoto
2010-04-14 13:44:50
+2
A:
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.
e.James
2010-04-14 13:45:19