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

Objective-C Literals

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s