index rss mastodon twitter github linkedin email
Álvaro Ramírez
sponsor

Álvaro Ramírez

18 February 2016 Some modern Objective-C idioms

NSNumber literals

NSNumber *number1 = @1024;
NSNumber *number2 = @1024.123f;
NSNumber *number3 = @'A';
NSNumber *number4 = @YES;
NSNumber *number5 = @24ul; // Unsigned long.
NSNumber *number6 = @123456ll; // Long Long.
NSNumber *number7 = @5050.50; // Float.
NSNumber *number8 = @1543; // Integer
NSNumber *number9 = @111.456; // Double

Array literals

NSArray *names = @[@"John\n", @"Peter\n", @"Jaye\n", @"George\n", @"Max"];
NSArray *mutableNames = [@[@"John\n", @"Peter\n", @"Jaye\n", @"George\n", @"Max"] mutableCopy];