Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting NSArray to NSMutableArray [closed]

As above. Would be helpful to know. Thanks!

like image 574
Sidwyn Koh Avatar asked Jul 11 '10 06:07

Sidwyn Koh


People also ask

What is difference between NSArray and NSMutableArray?

The primary difference between NSArray and NSMutableArray is that a mutable array can be changed/modified after it has been allocated and initialized, whereas an immutable array, NSArray , cannot.

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 .

Is NSArray ordered?

An object representing a static ordered collection, for use instead of an Array constant in cases that require reference semantics.


1 Answers

Here are two options:

- (NSMutableArray *)createMutableArray1:(NSArray *)array {     return [NSMutableArray arrayWithArray:array]; }  - (NSMutableArray *)createMutableArray2:(NSArray *)array {     return [[array mutableCopy] autorelease]; } 
like image 177
Cameron Spickert Avatar answered Sep 30 '22 20:09

Cameron Spickert