My model classes are mostly implemented using synthesized setter / getter methods, and everything was fine. Everything was well connected to the user interface. Later I realized that changing one property should lead to changing other properties (changing type
can lead to changes in minA
and maxA
), so I manually wrote the setter / getter methods for the type
property. Code follows:
QBElementType
@interface QBElementType : NSObject @property NSRange minRange; @property NSRange maxRange; @end @implementation QBElementType @synthesize minRange; @synthesize maxRange; @end
QBElement
@interface QBElement : QBElementType{ QBElementType *_type; } @property (weak) QBElementType *type; @property NSUInteger minA; @property NSUInteger maxA; @end @implementation QBElement @synthesize minA = _minA; @synthesize maxA = _maxA; - (QBElementType*)type { return _type; } - (void)setType:(QBElementType*)newType { [self willChangeValueForKey:@"type"]; _type = newType;
QUESTION Since when I change the type of an element, I get an uncaught exception:
Unable to update for observer <NSTableBinder ...> for the key path "type.minRange" from <QBElement ...>, most likely because the value for the key "type" was changed without a corresponding KVO notification sent. Verify that the KVO matches the QBElement class.
Is there something obvious I'm missing from KVO-Compliance ? Why am I getting this error?
user1040049
source share