OC中所有id都是一个** objc_object **对象
objc_object包含:
isa_t
关于isa操作相关
弱引用相关
关联对象相关
内存管理相关
屏幕快照 2018-11-17 上午10.20.47.png
objc_class包含:
Class ->
objc_class (继承自 objc_object ) 结构体
superClass (父类)
cache_t (方法缓存)
class_data_bits_t (变量 属性 方法)

isa 指针:
共用体 isa_t :
{
指针型isa (isa的值代表 class地址 )
非指针型isa (isa的值得部分代表class的地址)
}
isa 指向:
关于对象 其指向类对象
实例 -isa -> class
关于类对象 其指向元类对象
class -isa- > metaClass(元类对象)

cache_t 指向:
用于快速查找方法执行函数
它是一个可增量扩展的哈希表结构 (提高查找效率)
是局部性原理的最佳应用(局部性原理: 把调用频次最高的放在缓存中 就是局部性原理实现)
cache_t 是由 多个 bucket_t (结构体)
bucket_t 包含 { key: IMP }

class_data_bits_t 指向:
class_data_bits_t 主要是对class_rw_t的封装
class_rw_t代表了类相关的读写信息 对class_ro_t的封装
class_ro_t 代表类的相关只读信息
class_rw_t包含 :
class_ro_t
protocols
properties
methods

class_ro_t包含 :
name
ivars(类的成员变量)
properties(属性)
peotocols(协议)
methodList(方法列表)

method_t包含 :
函数四要素:
名称
返回值
参数
函数体
method_t:
SEL name;
const chat* types(函数返回值和参数组合)
IMP imp(无类型函数指针 对应是函数体)

Type Encodings :
const xhar* types;

整体数据结构 :

网友评论