开发者

Getting list of class methods

开发者 https://www.devze.com 2023-04-03 16:30 出处:网络
I\'m looking for a way to get a开发者_Go百科 static methods list for a certain class. I only geta list of instance methods with the runtime function class_copyMethodList().

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号