美文网首页iOS进阶干货分享
iOS Runtime面试题(说一下对 class_rw_t 的

iOS Runtime面试题(说一下对 class_rw_t 的

作者: _小迷糊_997 | 来源:发表于2019-07-27 16:24 被阅读3次

说一下对 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 !结实人脉、讨论技术你想要的这里都有!

相关文章

网友评论

    本文标题:iOS Runtime面试题(说一下对 class_rw_t 的

    本文链接:https://www.haomeiwen.com/subject/boyerctx.html