Fact 4: The id Type Is a Generic Pointer Type

Because objects are referenced through pointers, which are just memory addresses, you can freely assign them between id variables. A method that returns an id type consequently just returns a pointer to some object in memory. You can then assign that value to any object variable. Because the object carries its isa member wherever it goes, its class can always be identified, even if you store it in a generic object variable of type id.

Get Programming in Objective-C, Sixth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.