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];
- Is
@[]equal to[NSMutableDictionary dictionary]? - Is
@{}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].