Make it Technical: NSArray/NSDictionary literal syntax

Optimisation tricks for engineers

NSArray Literals

Previously:

array = [NSArray arrayWithObjects:a, b, c, nil];

Now:

array = @[ a, b, c ];

NSDictionary Literals

Previously:

dict = [NSDictionary dictionaryWithObjects:@[o1, o2, o3] forKeys:@[k1, k2, k3]];

Now:

dict = @{ k1 : o1, k2 : o2, k3 : o3 };

http://stackoverflow.com/questions/9347722/what-are-the-details-of-objective-c-literals-mentioned-in-the-xcode-4-4-releas

發表留言