Converting NSArray to NSMutableArray

Sidwyn Koh picture Sidwyn Koh · Jul 11, 2010 · Viewed 50.4k times · Source

As above. Would be helpful to know. Thanks!

Answer

Cameron Spickert picture Cameron Spickert · Sep 2, 2011

Here are two options:

- (NSMutableArray *)createMutableArray1:(NSArray *)array
{
    return [NSMutableArray arrayWithArray:array];
}

- (NSMutableArray *)createMutableArray2:(NSArray *)array
{
    return [[array mutableCopy] autorelease];
}