Hey, shortcuts are nice, but what about this Objective-C monstrosity:
NSMutableArray *returnArray = [@[] mutableCopy];
Guh. I kind of wrote this because I could, but I think this is much better:
NSMutableArray *returnArray = [NSMutableArray new];
While we’re at it, since this is for a function that is going to return an immutable NSArray, why not go for a name that reflects what is actually going on?
NSMutableArray *mutableReturnArray = [NSMutableArray new];
Finally, when it’s time:
return [mutableReturnArray copy];
A word of warning, this last step seems to be unnecessary for the running of an app, but I’m told that this doesn’t make much sense, since the debugger will still see this as a mutable array. It might seem pedantic, but it’s apparently correct. Has this ever bitten you?