The isa Pointer in Objective-C

Introduction In , is the root class for most classes. It has an property of type . What is ? And what is ? isa The definition of in : is a pointer to an struct, and is a pointer to an struct. Now let's look at the definition of in : - isa: A pointer of type . Every instance object has an pointer pointing to its class, and the itself also has an pointer pointing to its . The metaclass stores the list of class methods. When a class method is called, the runtime first looks for the implementation in the class itself; if not found, the metaclass searches its parent class. Note that a metaclass () is itself a class and therefore also an object. Metaclasses also have pointers, and those ultimately point to a root metaclass (). The root metaclass's pointer points to itself, forming a closed loop. - superclass: The superclass. If this class is already the topmost root class, this is . - version: Class version info, default 0. - info: Some bit flags used at runtime. - instancesize: The size of the class's instance variables. - ivars: An array of member variables. - methodLists: An array of method definitions. - objccache: Points to recently used methods, used to optimize method dispatch. - protocols**: An array of protocols. An additional note on metaclasses (): Core rule: An instance object's points to its class; the class's points to its metaclass. In plain terms: instance methods are recorded in the ; class methods are recorded in the . That is, the information for an lives in the , and the information for the lives in the . The inheritance relationships for class instance variables: Every object is fundamentally an instance of a class. The class defines the list of member variables and methods. An object points to its class via the object's pointer. Every class is fundamentally an object — a class is actually an instance of its metaclass (). The metaclass defines the list of class methods. A class points to its metaclass via the class's pointer. All metaclasses ultimately inherit from a root metaclass, whose pointer points to itself, forming a closed loop.