arm*_*ahg 25 cocoa properties introspection objective-c key-value-observing
是否有一个方法返回符合NSKeyValueCoding协议的对象的所有键?
沿着这条线的东西[object getPropertyKeys]将返回NSString对象的NSArray.它适用于任何符合KVC标准的对象.这种方法存在吗?到目前为止,我还没有找到任何搜索Apple文档的内容.
谢谢,G.
oxi*_*gen 38
#import "objc/runtime.h"
unsigned int outCount, i;
objc_property_t *properties = class_copyPropertyList([self class], &outCount);
for(i = 0; i < outCount; i++) {
objc_property_t property = properties[i];
const char *propName = property_getName(property);
if(propName) {
const char *propType = getPropertyType(property);
NSString *propertyName = [NSString stringWithUTF8String:propName];
NSString *propertyType = [NSString stringWithUTF8String:propType];
}
}
free(properties);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10947 次 |
| 最近记录: |