First let’s define a class

Wonder “will the current class be as exploitable as our objects? So there’s more than one class in memory?”

Now let’s start to verify, are these addresses consistent?

The print results are surprisingly consistent, but 0x100008360- it’s not a class, so what is it?

The isa of an object points to a class. The ISA of a class points to a metaclass (which is generated and compiled by the system). What about the ISA of a metaclass? To what?

As shown in the figure below, isa of the root class points to isa of the root metaclass by using p/x instruction successively:

In the code

Conclusion: The parent of the metaclass is the current root metaclass

Continue to explore

The output

NSObject – 0x7fff806fdfe0 HLPerson – 0x100008338

Is something wrong? How is it inconsistent with the pointing judgment shown above?

HLTeacher inheritance -> HLPerson inheritance -> NSObject such a chain of inheritance

Metaclasses also have an inheritance chain

The other problem is that whenever you get to NSOject you get special cases

Output (NULL) -0x0

NSObject – 0x7fff806fe008

Nsobject-0x7fff806fe008 is the same as the above class and is back to square one. So we’re back to NSObject.

Then look at the official ISA flowchart

To be continued……