The ISA attribute of the previous to NSObject also know point, but understand not deep, today read this post, feel very good, summarize:
http://chun.tips/blog/2014/11/05/bao-gen-wen-di-objective%5bnil%5dc-runtime-(2)%5Bnil% 5d-object-and-class-and-meta-class/
First put the most important picture on the inside:
We are looking at a few important definitions:
/// An opaque type, represents an Objective-c class. struct objc_class *class; /// represents an instance of a class. struct objc_object { Class isa objc_isa_availability;}; /// A pointer to a instance of a class. struct objc_object *ID;
Here is another mention: In fact, the ID is not nsobject *, but the struct objc_object *, then why can the ID point to any NSObject object? Because Objc_object has only one class-type ISA variable, this structure is exactly the same as the NSObject definition:
@interface NSObject <NSObject> { Class isa objc_isa_availability;}
In this way, the content at the first address of the NSObject object can be pointed to by the ID. Because essentially, the object's data is stored by the struct.
Look at the definition:
structObjc_class {class Isa objc_isa_availability;#if!__objc2__Class Super_class objc2_unavailable; Const Char*name objc2_unavailable; Longversion objc2_unavailable; Longinfo objc2_unavailable; Longinstance_size objc2_unavailable; structObjc_ivar_list *Ivars objc2_unavailable; structObjc_method_list * *methodlists objc2_unavailable; structObjc_cache *Cache objc2_unavailable; structObjc_protocol_list *protocols objc2_unavailable;#endif} objc2_unavailable;
Although this is not a new version of the definition, but the basic concept of the same. In the OBJC_CLASS structure, there are also 2 pointers to the OBJC_CLASS structure, ISA and super.
When we call the class method of each ordinary object, we return a pointer to the Objc_class struct that corresponds to that class. An object of the same class, calling the class method, returns a pointer to the same objc_class struct body.
The role of Meta class in the diagram is not always understood, why do you need it? Are there any practical applications?
Type of ISA property for IOS NSObject Class