My interface has an NSTextField that value bound to NSArrayController's selection.selectedType.title . All NSArrayController's objects are user objects, each of which has two methods:
- (MYType *)selectedType; - (void)setSelectedType: (MYType *)type;
do not have iVar selectedType . However, they have an iVar containing all MYType objects. The code comes down to the following:
- (MYType *)selectedType { if (someIndex == 0) return [types objectAtIndex: 0]; else return [self typeWithIndex: someIndex]; } - (void)setSelectedType: (MYType *)type { someIndex = [type index]; }
MYType objects got iVar NSString *title with the corresponding @property and synthesize .
Whenever I call setSelectedType: changes are immediately visible in the NSTextField , and everything seems to work, but I get a message with the message:
It is not possible to remove the NSArrayController 0x141160 observer for the path key "selectedType.title" from MYType 0x1a4830, most likely because the value for the "selectedType" key has changed without sending a corresponding KVO notification. Check the KVO correspondence of the MYType class.
I tried encapsulating the setSelectedType: method with willChangeValueForKey: and didChangeValueForKey: and then I got a log message, but another:
Cannot remove observer NSKeyValueObservance 0x1c7570 for key path "title" from MYType 0x1a4be0, because it is not registered as an observer.
source share