How to convert an NSArray into an NSMutableArray

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];

Leave a Reply

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