Exception rasied if modified the class's property
smalllixin opened this issue · comments
LiXin commented
Hi nick,
I am trying to adopt fastcoding lib. I found if the class property deleted or renamed will get a entire uninitialized object.
The reason I found setValue to a non existed property will raise an exception:
for (__unsafe_unretained NSString *key in definition->_propertyKeys)
{
[object setValue:FCReadObject(decoder) forKey:key];
}
The quick fix is add a try-catch to prevent the exception.
for (__unsafe_unretained NSString *key in definition->_propertyKeys)
{
@try {
[object setValue:FCReadObject(decoder) forKey:key];
}
@catch (NSException *exception) {
}
}
However if there is another better solution?
Nick Lockwood commented
You could override setValue:forUndefinedKey: on your class and have it do nothing instead of crashing.
LiXin commented
Wow, this feels better. Thank u.