Re:Objective-C literals for NSDictionary, NSArray, and NSNumber
by icodestuff on Sunday February 19, 2012 @05:23PM
(#3610613)
Could be in case they want to do literal NSValues later. Since {}-syntax is used in C for both array literals and struct literals, they needed to change one, and the picked the more common one. Otherwise is foo in:
id foo = @{ @2, @5 };
an NSArray containing two NSNumbers, or an NSValue containing a struct with two pointers (which happen to be NSNumber *s)?
I'd guess there were other edge cases they didn't want to deal with, so they didn't do literal NSValues for this release.
Or it could be that it's because []-style arrays are popular these days.
Or some of both; in picking which {} to change to @[], they reasoned that lots of people have experience with []-style arrays.
id foo = @{ @2, @5 };
an NSArray containing two NSNumbers, or an NSValue containing a struct with two pointers (which happen to be NSNumber *s)?
I'd guess there were other edge cases they didn't want to deal with, so they didn't do literal NSValues for this release.
Or it could be that it's because []-style arrays are popular these days.
Or some of both; in picking which {} to change to @[], they reasoned that lots of people have experience with []-style arrays.