Last Updated: February 25, 2016
·
531
· jure

Objective-C literals

Very useful stuff.

Numbers

NSNumber *myInt = @1337;
NSNumber *myFloat = @13.37;

Arrays

NSArray *array = @[ @"first", @"second", @"third" ];
NSString *object = array[0]; // first

Dictionaries

NSDictionary *dictionary = @{ @"firstKey": @"firstValue", @"secondKey" : @"secondValue", @"thirdKey" : @"thirdValue" };
NSString *value = dictionary[@"firstKey"]; // firstValue