Objective-C Literals

Staring Apple LLVM Compiler 4.0, Objective-C Literals were introduced:

  • NSNumber Literals provide a syntax for creating NSNumber from scalar literal expressions;
  • Collection Literals provide a short-hand for creating arrays and dictionaries;
  • Object Subscripting provides a way to use subscripting with Objective-C objects.

They make Obj-C much easier to write.
Below is a loaded example for quick reference:
NSArray *A = @[ @3.14, @(-INT_MAX/(1<<16))];
NSLog(@"%@ %@", A[0], A[1]);

Learn more from LLVM.org

Advertisements
Objective-C Literals