31

As above. Would be helpful to know. Thanks!

2
  • 9
    adding "need this urgently" is likely to have the opposite effect... Commented Jul 11, 2010 at 6:40
  • This is like the third exact question on NSArray and NSMutableArray's today. Commented Jul 11, 2010 at 7:10

3 Answers 3

85

Here are two options:

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

- (NSMutableArray *)createMutableArray2:(NSArray *)array
{
    return [[array mutableCopy] autorelease];
}
Sign up to request clarification or add additional context in comments.

1 Comment

Here's a conversion back to an NSArray: NSArray *array = [NSArray arrayWithArray:mutableArray];
18

Use -mutableCopy and make sure to balance the retain count.

NSMutableArray *mutableArray = [[immutableArray mutableCopy] autorelease];

2 Comments

It's now: NSMutableArray *mutableArray = [immutableArray mutableCopy];
@MarcelMarino That's correct!
11

Try this one

NSMutableArray *array = [[NSMutableArray alloc]initWithArray:your_array_name];

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.