How to convert an NSArray into an NSMutableArray

- by

There’s a handy function called arrayWithArray that we can use:

NSMutableArray *myNewArray = [[NSMutableArray alloc]init];
myNewArray = [NSMutableArray arrayWithArray:myOldArray];

Likewise we can convert a mutable array into a standard one:

NSArray *myStandardArray = [[NSArray alloc]init];
myStandardArray = [NSArray arrayWithArray:myMutableArray];

Add your voice!

This site uses Akismet to reduce spam. Learn how your comment data is processed.