The “Objective-C for Java Programmers, Part 1” intro by David Chisnall states that
Because you can have multiple base classes, Objective-C introduces the
id type to represent a pointer to some kind of object. You can
implicitly cast between any object type and id.
To the best of my understanding, Objective-C is single-inheritance (just like Java, but unlike C++).
So what does “multiple base classes” mean (in this context)?
It means that you can define your own root or “base” class.
Note that it does not inherit from
NSObject.In practice, this is never done because said class can’t really be used inter-operably with the rest of the system APIs because they all expect
NSObjectinherited behavior.That isn’t really the motivation behind the
idtype, though. Theidtype means, quite literally, this object reference can be an instance of any class.That there may be multiple base classes is entirely orthogonal.
No, implementing the
NSObject@protocolisn’t really good enough.