Possible Duplicate:
What are the details of “Objective-C Literals” mentioned in the Xcode 4.4 release notes?
I've got question about @[]
and @{}
.
Some code taken from internet:
self.searches = [@[] mutableCopy];
self.searchResults = [@{} mutableCopy];
@[]
equal to [NSMutableDictionary dictionary]
?@{}
equal to [NSMutableArray array]
?@[]
is equal to [NSArray array]
or [[NSArray alloc] init]
.@{}
is equal to [NSDictionary dictionary]
or [[NSDictionary alloc] init]
.(depending on the context and whether you use Automatic Reference Counting (ARC) or not)
That's why you see things like [@[] mutableCopy]
sometimes. This will create an empty immutable array and create a mutable copy of it.
The result is the same as using [NSMutableDictionary dictionary]
or [[NSMutableDictionary alloc] init]
.
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