OC中的类在编译完成之后是结构体,分别包含了那些数据?

 

struct objc_class {
    Class _Nonnull isa  OBJC_ISA_AVAILABILITY; // 指向元对象的指针
    #if !__OBJC2__
    Class _Nullable super_class  OBJC2_UNAVAILABLE; // 父对象
    const char * _Nonnull name OBJC2_UNAVAILABLE; // 类名
    long version OBJC2_UNAVAILABLE; // 版本
    long info  OBJC2_UNAVAILABLE; // 其他信息
    long instance_size OBJC2_UNAVAILABLE; // 实例大小
    struct objc_ivar_list * _Nullable ivars  OBJC2_UNAVAILABLE; // 属性列表
    struct objc_method_list * _Nullable * _Nullable methodLists OBJC2_UNAVAILABLE; //  方法列表                  
    struct objc_cache * _Nonnull cache OBJC2_UNAVAILABLE; // 方法缓存地址
    struct objc_protocol_list * _Nullable protocols  OBJC2_UNAVAILABLE; // 协议列表
    #endif
} OBJC2_UNAVAILABLE;

 

一个对象的isa指针指向的是它的类对象。

类对象分别包含了:指向元对象的指针、父对象、类名、版本、其他信息、实例大小、属性列表、方法列表、方法缓存地址、协议列表

 

posted on 2020-02-22 15:50  xiao孛  阅读(273)  评论(0编辑  收藏  举报