How to convert an immutable array to a mutable array

[snippets_intro text=”to convert an immutable array to a mutable array”]

When you have an immutable NSArray and want an NSMutableArray try this:

// converting from an immutable array to a mutable array:
NSArray *myArray = methodToReturnAnNSArray();
NSMutableArray *myMutableArray = [myArray mutableCopy];
[myArray release];

See also the reverse process here.

 
 

Lasă un răspuns

Adresa ta de email nu va fi publicată. Câmpurile obligatorii sunt marcate cu *