I am (trying to) learn Objective-C and I keep coming across a phrase like:
-(id) init;
And I understand id is an Objective C language keyword, but what does it mean to say “the compiler specifically treats id in terms of the pointer type conversion rules”?
Does id automatically designate the object to its right as a pointer?
idis a pointer to any type, but unlikevoid *it always points to an Objective-C object. For example, you can add anything of typeidto an NSArray, but those objects must respond toretainandrelease.The compiler is totally happy for you to implicitly cast any object to
id, and for you to castidto any object. This is unlike any other implicit casting in Objective-C, and is the basis for most container types in Cocoa.