I'm looking for a way to get a开发者_Go百科 static methods list for a certain class. I only get a list of instance methods with the runtime function class_copyMethodList()
.
Is there a way to list static methods?
Each Class
is itself an Objective-C object, and in turn has an object which is (sort of) its class. You need to get this metaclass object (see also: "[objc explain]: Classes and Metaclasses"), and then ask that for its methods (which will be the class methods* you are after).
From the class_copyMethodList
docs:
###Discussion To get the class methods of a class, use
class_copyMethodList(object_getClass(cls), &count)
*There's no such thing as static methods in Obj-C.
精彩评论