Re: KVO Question: How to programmatically determine if one object is observing another on a keyPath and context?
Re: KVO Question: How to programmatically determine if one object is observing another on a keyPath and context?
- Subject: Re: KVO Question: How to programmatically determine if one object is observing another on a keyPath and context?
- From: Fritz Anderson <email@hidden>
- Date: Sun, 09 Sep 2012 18:17:06 -0500
On 9 Sep 2012, at 3:50 PM, Motti Shneor <email@hidden> wrote:
> Nope. When representedObject becomes nil, I DO NOT WANT to observe anything, and I need to remove the observance from the previous representedObject, BEFORE it is set to nil on my NSViewController.
>
> If I added myself as an observer to a specific object, in the following way:
>
> [self.representedObject addObserver:self forKeyPath:@"incomingNotes" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:nil];
>
> than it is MY responsibility to remove myself from that object, just before losing it (e.g. as my representedObject is set to nil).
Perhaps I'm missing something. (I don't have the earlier part of the thread before me.) By "I observe," you mean an observation on .representedObject, by an instance of the NSViewController subclass?
Can't you just override setRepresentedObject:, and adjust your observations accordingly?
— F
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden