Is there a literal syntax for mutable collections?

ma11hew28 picture ma11hew28 · Sep 14, 2012 · Viewed 14.9k times · Source

I know I can create an NSArray with @[@"foo", @"bar"] or an NSDictionary with @{@0 : @"foo", @1 : @"bar"}.

Is there a literal syntax for creating an NSMutableArray or an NSMutableDictionary?

Answer

danielbeard picture danielbeard · Sep 14, 2012

There isn't a built in way, but I just usually use mutableCopy like this:

NSMutableArray *array = [@[ @"1", @"2", @"3" ] mutableCopy];