Is it possible to return a list of all the properties implemented by an object in Objective-C? I understand the properties are just getters and setters so I'm not sure how it would work. If this cannot be done, then is it possible to return all the selectors that an object will respond to? I'm looking for something similiar to the "methods" method in Ruby.
// Get properties list
objc_property_t* class_copyPropertyList(Class cls, unsigned int *outCount);
// Get methods list
Method* class_copyMethodList(Class cls, unsigned int *outCount);
The following code will output all methods implemented in UIImage class to console:
unsigned int count;
Method* methods = class_copyMethodList([UIImage class], &count);
for (size_t i = 0; i < count; ++i)
NSLog([NSString stringWithCString:sel_getName(method_getName(methods[i]))]);
free(methods);
I was actually trying out this yesterday and it is possible, however you cannot get everything from UIView. Take a look at the Objective-C Runtime Reference
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