Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSMutableArray removeObjectAtIndex

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?

like image 668
Cocoa Dev Avatar asked May 03 '11 20:05

Cocoa Dev


People also ask

What is NSMutableArray?

The NSMutableArray class declares the programmatic interface to objects that manage a modifiable array of objects. This class adds insertion and deletion operations to the basic array-handling behavior inherited from NSArray .

What is swift NSArray?

NSArray is an immutable Objective C class, therefore it is a reference type in Swift and it is bridged to Array<AnyObject> . NSMutableArray is the mutable subclass of NSArray .


1 Answers

From the NSMutableArray documentation:

To fill the gap, all elements beyond index are moved by subtracting 1 from their index.

like image 97
Dirk Avatar answered Oct 05 '22 14:10

Dirk