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?
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With