在我的模型基类中,我有一个如此定义的方法:
- (NSDictionary *)propertyDictionary
{
NSMutableDictionary *props = [NSMutableDictionary dictionary];
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];
NSString *propertyName = [NSString stringWithCString:property_getName(property) encoding:NSUTF8StringEncoding];
id propertyValue = [self valueForKey:(NSString *)propertyName];
if (propertyValue) [props setObject:propertyValue forKey:propertyName];
}
free(properties);
return props;
}
现在,直到一两天,这很有效。但是,现在有了某些对象,我突然得到像
这样的异常this class is not key value coding-compliant for the key title.
奇怪的是,我的类不再具有声明的属性,'title' - 我从对象中删除了该属性。是什么赋予了?为什么我会从class_copyPropertyList
获取不正确的属性列表?帮助!
答案 0 :(得分:0)
啊找到了它!
我将对象声明为符合类别中的<MKAnnotation>
。由于该对象不再具有title
和subtitle
的自己的访问者,但MKAnnotation需要它们,我得到了崩溃