How to decipher “objc_method_description” from protocol method description list?

后端 未结 1 1962
没有蜡笔的小新
没有蜡笔的小新 2021-02-11 01:54

I have some Swift 3 code to decode an iOS Objective-C protocol (which has a Swift counterpart). After concluding Swift 3 reflection was not developed enough to accomplish what I

1条回答
  •  囚心锁ツ
    2021-02-11 02:33

    What is returned objc_method_description.type field?

    • A method signature encoding scheme
    • ... which includes an obsolete stack offset representation

    In other words, to get a usable method signature encoding from the type field, just just extract the alpha-symbolic characters in left-to-right order discarding the digits.

    Supporting documentation:

    • Objective-C Method Signature Type Encoding
    • Meaning of the numeric elements in signature encoding, explained by an Apple developer
    • Playing around with Type Encodings
    • class_addmethod (according to @Richard_J_Ross, this is the root of it)
    • Objective-C Runtime Programming Guide
    • Objective-C Runtime Reference

    0 讨论(0)
提交回复
热议问题