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

后端 未结 1 1459
孤城傲影
孤城傲影 2021-02-11 01:58

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:24

    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)
提交回复
热议问题