Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting list of class methods

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?

like image 476
Laurynas Avatar asked Sep 08 '11 07:09

Laurynas


People also ask

How do I get a list of methods in Python?

There is the dir(theobject) method to list all the fields and methods of your object (as a tuple) and the inspect module (as codeape write) to list the fields and methods with their doc (in """). Because everything (even fields) might be called in Python, I'm not sure there is a built-in function to list only methods.

How do I get all the methods of a class in Python?

To list the methods for this class, one approach is to use the dir() function in Python. The dir() function will return all functions and properties of the class.

Can you make a list of methods in Python?

In Python, you can use a list function which creates a collection that can be manipulated for your analysis. This collection of data is called a list object. While all methods are functions in Python, not all functions are methods.


1 Answers

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.

like image 171
jscs Avatar answered Sep 27 '22 23:09

jscs