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.

Leave a Reply

Your email address will not be published. Required fields are marked *