oc,你关注的runtime


Method类型是一个objc_method结构体指针,而结构体objc_method有三个成员:

         An opaque type that represents a method in a class definition.typedef struct objc_method *Method;struct objc_method
  • SEL method_name;
    // 方法名称

  • char *method_typesE;
    // 参数和返回类型的描述字串,平常我们调用方法传递的参数和调用方法返回值

  • IMP method_imp;
    // 方法的具体的实现的指针,指向了方法实现的指针

Method所有方法


// 函数调用,但是不接收返回值类型为结构体

method_invoke

  // 函数调用,但是接收返回值类型为结构体

method_invoke_stret

  // 获取函数名

method_getName

 // 获取函数实现IMP

method_getImplementation

// 获取函数type encoding

method_getTypeEncoding

// 复制返回值类型

method_copyReturnType

// 复制参数类型

method_copyArgumentType

// 获取返回值类型

method_getReturnType

// 获取参数个数

method_getNumberOfArguments

// 获取函数参数类型

method_getArgumentType

// 获取函数描述

method_getDescription

  // 设置函数实现IMP

method_setImplementation

 // 交换函数的实现IMP

method_exchangeImplementations

实例

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容