Fact 1: Instance Variables Are Stored in Structures

When you define a new class and its instance variables, those instance variables are actually stored inside a structure. That’s how you can manipulate objects; they’re really structures whose members are your instance variables. So, the inherited instance variables plus the ones you added in your class comprise a single structure. When you allocate a new object using alloc, enough space is reserved to hold one of these structures.

One of the inherited members (it comes from the root object) of the structure is a protected member called isa that identifies the class to which the object belongs. Because it’s part of the structure (and, therefore, part of the object), it is carried around with ...

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.