|
|
|
|
|
by jonhohle
5487 days ago
|
|
Objective-C types are optional and the language is dynamic, and that's considered (by Apple and most Objective-C developers) a feature. id something = nil;
[something countForObject: nil];
Completely valid, won't crash your program, and only enough type information to satisfy the compiler (but largely meaningless for anything but the most basic static analysis). The only requirement for the above to compile is that countForObject: is a selector defined somewhere in the include path for the file. Even that is a relatively soft requirement since you can pass arbitrary selectors to any object.And none of this has anything to do with ARC, as far as I can tell. There was a first class language on Mac OS X which was fully statically typed. It was deprecated with Leopard and never introduced on iOS. The dual nature of Objective-C is one of its attractive properties. |
|
The support for 'id' is only intended to serve as a mechanism to get around the lack of parameterized types, and as part of ARC, the compiler does now infer the types for alloc/init.