Getting a list of class methods

I am looking for a way to get a list of static methods for a specific class. I only get a list of instance methods using the runtime function class_copyMethodList() .

Is there a way to list static methods?

+8
objective-c objective-c-runtime
source share
1 answer

Each Class itself is an Objective-C object and, in turn, has an object that is (kind of) its class. You should get this metaclass object (see also: “[objc explain]: Classes and metaclasses” ), and then ask what its methods are (which will be the class methods * you are after).

From class_copyMethodList docs:

Discussion

To get class methods of a class, use class_copyMethodList(object_getClass(cls), &count)


* There is no such thing as static methods in Obj-C .

+17
source share

All Articles