9

I'm looking for a way to get a 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?

jscs
  • 63,694
  • 13
  • 151
  • 195
Laurynas
  • 3,829
  • 2
  • 32
  • 22
  • You mean a list of class methods? How about checking an every method using class_getClassMethod function with the method list from class_copyMethodList function? – Kazuki Sakamoto Sep 08 '11 at 07:42
  • 1
    Thanks for response. But with class_copyMethodList I get only instance methods, static methods (defined with +) are not included. – Laurynas Sep 08 '11 at 07:53

1 Answers1

18

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.

Dimitar Nestorov
  • 2,411
  • 24
  • 29
jscs
  • 63,694
  • 13
  • 151
  • 195