Reputation: 9541
If I have an NSMutableArray with 10 objects
I run this line of code
[tempArray removeObjectAtIndex:0];
then
[tempArray count]
should return 9
but does the entire Array shift up
Object At Index 1 moves to Index 0
Object at Index 2 moves to Index 1
...
Object at Index 9 moves to Index 8
or is Index 0 = nil?
Upvotes: 5
Views: 6626
Reputation: 20710
removeObjectAtIndex
shifts indexes down
insertObjectAtIndex
shifts indexed up
addObject
adds object at the end so there is no shifting
Upvotes: 0
Reputation: 31053
From the NSMutableArray documentation:
To fill the gap, all elements beyond index are moved by subtracting 1 from their index.
Upvotes: 7
Reputation: 57169
The array will shift all of the objects down 1 from the right of the removed index. Index 0 will be what was at index 1 and so forth.
Upvotes: 2