Changes in new versions / Objective-C 2012: Literals

// *** before: ***
// a collection was built by a factory method with a nil at the end, and a
// forgotten nil quietly cut the list short or read past it
NSArray *names = [NSArray arrayWithObjects:@"Ann"@"Bob"@"Cate"nil];

NSDictionary *ages = [NSDictionary dictionaryWithObjectsAndKeys:
                      @"31"@"Ann",      // the value comes FIRST, then the key
                      @"27"@"Bob"nil];

NSMutableArray *queue = [NSMutableArray arrayWithObjects:@"first"nil];

// *** in version 2012: ***
// the literal is shorter and the order inside the dictionary is the usual
// key: value one
NSArray *names = @[@"Ann"@"Bob"@"Cate"];

NSDictionary *ages = @{@"Ann"@"31",
                       @"Bob"@"27"};

NSMutableArray *queue = [@[@"first"mutableCopy];   // a literal is immutable

// a trailing comma is allowed, which makes a diff of one added line clean
NSArray *cities = @[
    @"Kazan",
    @"Perm",
];

// ⚠️ nil inside a literal is a crash at run time, not a shortened array:
// @[first, second] throws if second is nil. The old arrayWithObjects:
// simply stopped at that place