iOS Runtime面試題(說一下對 class_rw_t 的理解?)

說一下對 class_rw_t 的理解?面試

rw表明可讀可寫。數組

ObjC 類中的屬性、方法還有遵循的協議等信息都保存在 class_rw_t 中:ui

// 可讀可寫
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;
    
    //...
    }

熱文推薦

2019 全網 iOS 面試題以及答案總結!

相關文章
相關標籤/搜索