Apple committed a new patch to the llvm project adding support for new Objective-C literalsyntax for NSArray
, NSDictionary
and NSNumber
. These have previously been documented in the Mountain Lion Xcode release notes but that was still under NDA. Now that these features have been committed to llvm I guess we’re allowed to speak about it.
Add clang support for new Objective-C literal syntax for NSDictionary, NSArray,
NSNumber, and boolean literals. This includes both Sema and Codegen support.
Included is also support for new Objective-C container subscripting.My apologies for the large patch. It was very difficult to break apart.
The patch introduces changes to the driver as well to cause clang to link
in additional runtime support when needed to support the new language features.Docs are forthcoming to document the implementation and behavior of these features.
No official documentation is available yet outside the NDA, but examples can be derived from the LLVM unit tests.
NSNumber literals
1 2 3 4 5 6 7 8 |
|
NSArray literals
1 2 3 4 |
|
Note that it’s not needed to include the ending nil
sentinel anymore using the new syntax.
NSDictionary literals
1 2 3 4 5 6 |
|
As with NSArray
no need to include the nil
sentinel here either.