preface

In the previous section we have analyzed the first address of the object isa and analyzed the structure of the pure ISA and NONPOINTER_ISA and the process of restoring the class in two ways, but we need to explore the class ISA further.

The origin of introducing metaclasses

Let’s take a look at the source structure of the class

Classes also have a hidden parameter ISA

struct objc_object {

    Class **_Nonnull** isa  OBJC_ISA_AVAILABILITY;

};
Copy the code

From the inherited parent objc_objct

Think: what kind of ISA&ISA_MASK is it?

The code analysis

LGPerson *p = [LGPerson alloc];

 NSLog(@"%@",p);
Copy the code

So that brings up the idea of a metaclass why is it a metaclass?

MachOview analysis looks at metaclasses

You can see here that the metaclass is actually in the bottom of the apple

  • The metaclassIt is created automatically by the system compiler and has nothing to do with the user
  • The object’sisaPoint to theclassClass objectisaPoint to theThe metaclass
  • Of the classThe name of the classThe class associated with itThe metaclasstheThe name of the classIs the same (only associated metaclasses have class names)

Isa bitmap