Objective-C was quite verbose and lack of visual clue, however after Clang 3.5, there are quite a few improvements, these new language features allow us to write more clean code:
The “new” method
[Foo new]
is better than
[[Foo alloc] init]
if you don’t need to use custom init methods.
Object Subscripting
array[i] dictionary[key]
are better then
[array objectAtIndex:i] [dictionary objectForKey:key]
since they has more visual clues.
Primitive Literals
NSNumber *fortyTwo = @42;
is bettern then
[NSNumber numberWithInt:42]
since the syntax is consistent across int string char bool and enum types.
Container Literals
NSArray *array = @[ @"Hello", NSApp, @(i) ]; NSDictionary *dictionary = @{ @"name" : NSUserName(), @"date" : [NSDate date], @"processInfo" : [NSProcessInfo processInfo] };
Are better then the good old constructors.
By using these new language features, we would experience less cognitive load during programming.