在尝试获取在运行时提取的对象的属性值时,代码下方会导致EXC_BAD_ACCESS
objc_property_t *properties = class_copyPropertyList(myClass, &count);
for (int i = 0; i < count ; i++) {
NSString *propertyName = [NSString stringWithCString:property_getName(properties[i]) encoding:NSUTF8StringEncoding];
if ([object respondsToSelector:NSSelectorFromString(propertyName)]) {
id value = [object valueForKey:propertyName];
}
}
保护valueForKey
EXC_BAD_ACCESS
的任何建议?