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
The getMethods() method of java. lang. Class class is used to get the methods of this class, which are the methods that are public and its members or the members of its member classes and interfaces. The method returns the methods of this class in the form of an array of Method objects.
The simplest way to get a list of methods of any object is to use the help() command. It will list out all the available/important methods associated with that object.
There are three main types of methods: interface methods, constructor methods, and implementation methods.
Use the metaclass.
#import <objc/runtime.h>
int unsigned numMethods;
Method *methods = class_copyMethodList(objc_getMetaClass("NSArray"), &numMethods);
for (int i = 0; i < numMethods; i++) {
NSLog(@"%@", NSStringFromSelector(method_getName(methods[i])));
}
free(methods);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With