Yes, that approach is *so* much safer. When we switched over to doing it that 
way so many "dealloc called while object was being observed" problems went away.

----- Original Message -----
From: "Quincey Morris" <quinceymor...@rivergatesoftware.com>
To: "Motti Shneor" <su...@bezeqint.net>
Cc: "Cocoa-Dev List" <Cocoa-dev@lists.apple.com>
Sent: Sunday, September 9, 2012 4:26:27 PM
Subject: Re: KVO Question: How to programmatically determine if one object is   
observing another on a keyPath and context?

On Sep 9, 2012, at 13:50 , Motti Shneor <su...@bezeqint.net> wrote:

> On 9 בספט 2012, at 22:04, Ken Thomases wrote:
> 
>> Why is that a "however"?  What's the problem?  Since the representedObject 
>> is KVO-compliant, all observations _through_ that property will 
>> automatically follow it as it changes.
> 
> 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.

I think, by using the word "through", Ken is suggesting you do this:

        [self addObserver:self forKeyPath:@"representedObject.incomingNotes" 
...];

rather than this:

        [self.representedObject addObserver:self forKeyPath:@"incomingNotes" 
...];

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/lrucker%40vmware.com

This email sent to lruc...@vmware.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to