說一下對 class_rw_t
的理解?
rw
代表可讀可寫。
ObjC
類中的屬性、方法還有遵循的協議等信息都保存在 class_rw_t
中:
// 可讀可寫
struct class_rw_t {
// Be warned that Symbolication knows the layout of this structure.
uint32_t flags;
uint32_t version;
const class_ro_t *ro; // 指向只讀的結構體,存放類初始信息
/*
這三個都是二位數組,是可讀可寫的,包含了類的初始內容、分類的內容。
methods中,存儲 method_list_t ----> method_t
二維數組,method_list_t --> method_t
這三個二位數組中的數據有一部分是從class_ro_t中合並過來的。
*/
method_array_t methods; // 方法列表(類對象存放對象方法,元類對象存放類方法)
property_array_t properties; // 屬性列表
protocol_array_t protocols; //協議列表
Class firstSubclass;
Class nextSiblingClass;
//...
}
面試題持續整理更新中,需要拿到第一手大廠面試題及答案文檔可以添加 iOS進階學習交流羣:551346706 !結實人脈、討論技術你想要的這裏都有!