NSArray initialization methods
@[]
is shorthand for:
id a = nil;
NSArray* array = [NSArray arrayWithObjects:&a count:0];
It is really just a shorthand for [NSArray array]
for all intents and purposes.
This is a feature added to a specific version of the compiler (and doesn't really require runtime support for that specific syntax).
This is not at all like shorthand @""
in that it @""
creates a compile-time constant and does not result in run-time messaging. In fact, @""
(any @"sequence"
) is a special case in that it emits a compile-time constant that is implemented at runtime with zero messaging; zero dynamism. A @"..."
looks more like an Objective-C class than a regular object instance.
source to share