美文网首页
iOS category理解

iOS category理解

作者: 注册麻烦 | 来源:发表于2019-10-29 10:07 被阅读0次

    Extension 是在编译时,把信息合并到类信息中;

    -Catagory 是程序运行时,利用runtime机制合并到类信息中

    -Catagory的原理: Category再编译只之后生成一个底层结构struct category_t,里面存储着分类的对象方法,类方法,属性,协议。

    在程序运行的时候,Runtime会将category的数据,合并到类信息中。

    category的底层结构 category_t

    struct category_t {
    const char *name;
    classref_t cls;
    struct method_list_t *instanceMethods;
    struct method_list_t *classMethods;
    struct protocol_list_t *protocols;
    struct property_list_t *instanceProperties;
    struct property_list_t *_classProperties;
    }

    相关文章

      网友评论

          本文标题:iOS category理解

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