g.revolution
g.revolution

Reputation: 12262

Difference between NSArray and NSMutableArray

What is the difference b/w NSArray and NSMutableArray?

Upvotes: 62

Views: 44804

Answers (3)

Jagat Dave
Jagat Dave

Reputation: 1645

NSArray : in NSArray we can not change index.... Means fix array.

NSMutableArray : in NSMutableArray we can change index and also add the value in array at run-time..

Upvotes: 1

jtbandes
jtbandes

Reputation: 118671

NSMutableArray (and all other classes with Mutable in the name) can be modified. So, if you create a plain NSArray, you cannot change its contents later (without recreating it). But if you create an NSMutableArray, you can change it — you'll notice it has methods like -addObject: and -insertObject:atIndex:.

See the documentation for details.

Upvotes: 117

Shaggy Frog
Shaggy Frog

Reputation: 27601

The "mutable" types are classes which can be changed after they've been initialized, like NSMutableString vs NSString.

Upvotes: 5

Related Questions