类的定义
struct objc_class {
Class isa;
Class super_class;
const char *name;
long version;
long info;
long instance_size;
struct objc_ivar_list *ivars;
struct objc_method_list **methodLists;
struct objc_cache *cache;
struct objc_protocol_list *protocols;
}
struct objc_ivar {
char *ivar_name;
char *ivar_type;
int ivar_offset;
}
struct objc_ivar_list {
int ivar_count;
/* variable length structure */
struct objc_ivar ivar_list[1];
}
ivars 列表存放的是字段的定义?
实例的定义
typedef struct objc_object {
Class isa;
} *id;
只有一个成员(指向所属类的指针),那他的字段数据放在哪里呢?
The object initialization data is placed in the heap. The member variable pointers of the instance object are all in objc_ivar_list * ivars. The object finds the corresponding memory and accesses the data through the pointer. Do you understand this?