美文网首页
iOS method_t

iOS method_t

作者: 山杨 | 来源:发表于2021-11-03 20:14 被阅读0次
  • method_t 是对方法/函数的封装
struct method_t {
    // "big" method传统意义上的方法(用selector、类型和实现的三指针结构体)
    struct big {
        SEL name;// 函数名
        const char *types;// 编码(返回值类型、参数类型)
        MethodListIMP imp;// 指向函数的指针
    };
private:
    // "small" method是用名称、类型和实现3个相对偏移指针
    struct small {
        // 名称字段指向一个selector(共享缓存中),或者指向一个selref(在其他地方)
        RelativePointer<const void *> name;
        RelativePointer<const char *> types;
        RelativePointer<IMP> imp;
        ...
    };

public:
    // 与方法列表一起使用的指针修饰符。当方法列表中包含小方法时,设置指针的底部位。
    // 我们在其他地方使用底部位来区分大方法和小方法。
    struct pointer_modifier {
        template <typename ListType>
        static method_t *modify(const ListType &list, method_t *ptr) {...}
    };
    ...
};
  • SEL代表方法/函数名,一般叫选择器(selector),底层结构类似char*

    不同类中相同名字的方法,所对应的selector都相同且唯一。可以通过@Selector()和sel_registerName()获得

  • Type Encoding

    iOS文档中提供了@encode()指令,可以将具体的类型表示成字符串编码

相关文章

  • iOS 底层 method_t 中的 types

    iOS 底层 method_t 中的 types 上篇我们说到,method_t 其实就是一个结构体,存储着方法的...

  • iOS method_t

    iOS method_t 我们查看 OBJC 源码 主要看前三个属性。 从源码的 method 结构体可以知道,一...

  • iOS method_t

    method_t 是对方法/函数的封装 SEL代表方法/函数名,一般叫选择器(selector),底层结构类似ch...

  • method_t

    ?method_t是对方法\函数的封装 /// struct method_t { SEL name; //函...

  • Runtime底层解析 - 方法:method_t

    method_t method_t是对方法\函数的封装 断点查看方法 仿源码自定义ClassInfo.h,从源码中...

  • runtime-method

    method_t数据结构 SEL SEL获取 SEL转字符串 types 方法编码

  • 一、初识Runtime数据结构

    Runtime的数据结构主要包括objc_object、objc_class、isa 指针、method_t对象。...

  • 二十、Runtime之(四)方法-method

    一、method_t结构 1.1 IMP的本质就是函数地址(指向函数的指针) 1.2 Type Encoding

  • RunTime

    数据结构 objc_object objc_class isa指针 method_t objc_object id...

  • iOS-面试题2-Runtime、Runloop

    目录: isa存储信息分析 Class的内部结构、method_t、cache objc_msgSend底层调用流...

网友评论

      本文标题:iOS method_t

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