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

實例

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容