Get all methods of an Objective-C class or instance

前端 未结 4 1280
醉梦人生
醉梦人生 2020-12-07 12:38

In Objective-C I can test whether a given class or instance responds to certain selectors. But how can query a class or instance for all its methods or properties of a class

4条回答
  •  醉话见心
    2020-12-07 13:23

    This is possible via objc_method_list. In order to enumerate your methods, you will have to register all your methods before hand.

    The process is straight forward: after you've declared your function you can create an instance of objc_method and register the function name. Then add the objc_method to a objc_method_list and finally pass the objc_method_list to class_addMethods..

    Here is a link to get you started: http://theocacao.com/document.page/327

提交回复
热议问题