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
?
There isn't a built in way, but I just usually use mutableCopy
like this:
NSMutableArray *array = [@[ @"1", @"2", @"3" ] mutableCopy];
No. Just as how there isn't a syntax for creating an NSMutableString
either. Mutable objects are not particularly suited to literal values.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With