As above. Would be helpful to know. Thanks!
-
9adding "need this urgently" is likely to have the opposite effect...Mitch Wheat– Mitch Wheat2010-07-11 06:40:46 +00:00Commented Jul 11, 2010 at 6:40
-
This is like the third exact question on NSArray and NSMutableArray's today.Anurag– Anurag2010-07-11 07:10:35 +00:00Commented Jul 11, 2010 at 7:10
Add a comment
|
3 Answers
Here are two options:
- (NSMutableArray *)createMutableArray1:(NSArray *)array
{
return [NSMutableArray arrayWithArray:array];
}
- (NSMutableArray *)createMutableArray2:(NSArray *)array
{
return [[array mutableCopy] autorelease];
}
1 Comment
Nick N
Here's a conversion back to an NSArray: NSArray *array = [NSArray arrayWithArray:mutableArray];
Use -mutableCopy and make sure to balance the retain count.
NSMutableArray *mutableArray = [[immutableArray mutableCopy] autorelease];
2 Comments
Marcel Marino
It's now: NSMutableArray *mutableArray = [immutableArray mutableCopy];
falkon21
@MarcelMarino That's correct!