Iphone 返回Objective-C中对象的所有属性

Iphone 返回Objective-C中对象的所有属性,iphone,objective-c,Iphone,Objective C,是否可以返回Objective-C中对象实现的所有属性的列表? 我知道这些属性只是getter和setter,所以我不确定它将如何工作。如果无法执行此操作,那么是否可以返回对象将响应的所有选择器?我正在寻找与Ruby中的“方法”方法类似的东西 // Get properties list objc_property_t* class_copyPropertyList(Class cls, unsigned int *outCount); // Get methods list Meth

是否可以返回Objective-C中对象实现的所有属性的列表? 我知道这些属性只是getter和setter,所以我不确定它将如何工作。如果无法执行此操作,那么是否可以返回对象将响应的所有选择器?我正在寻找与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); 
以下代码将UIImage类中实现的所有方法输出到控制台:

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);
无符号整数计数;
方法*methods=class_copyMethodList([UIImage类],&count);
用于(大小i=0;i
我昨天确实尝试过这个,这是可能的,但是您无法从UIView获得所有信息。
看一看

看起来很棒,谢谢!要获取objc_属性,我需要导入什么?