Search code examples
objective-ccocoaobjective-c-runtime

Obtain list of class methods for an arbitrary class


How can I get the list of class methods for a particular Class? I've tried using the class_copyMethodList function declared in <objc/runtime.h>, but that's only giving me instance methods. I've also found a function that gives me a Method for a class method, but only if I have the selector to the method first (class_getClassMethod).

Any ideas?

Thanks,

Dave


Solution

  • class_copyMethodList returns the instance methods of the passed class. The class methods are actually instance methods of the class's metaclass.

    The solution to your problem is included right in the API Documentation for class_copyMethodList.