Re: removeObserver:forKeyPath:context: fails; but removeObserver:forKeyPath: works?!
Re: removeObserver:forKeyPath:context: fails; but removeObserver:forKeyPath: works?!
- Subject: Re: removeObserver:forKeyPath:context: fails; but removeObserver:forKeyPath: works?!
- From: Quincey Morris <email@hidden>
- Date: Thu, 12 Mar 2015 18:41:48 +0000
On Mar 12, 2015, at 03:01 , Jonathan Mitchell <email@hidden> wrote:
>
> But surely this is the whole point of the context - to be able to differentiate between multiple observations to the same object and path.
I think the point is to differentiate between multiple observations to the same object and path *from different objects*. I’m not convinced whether multiple observations to the same object and path to the same object are intended to be allowed or not.
Even if so, but if the observation created by the binding *doesn’t* use the context for removal — presumably because that piece of code predates the context-based removal API, and hasn’t been changed since — then the possibility for confusion still exists.
I found the original thread about the bug I referred to earlier:
http://www.cocoabuilder.com/archive/cocoa/239182-crash-in-kvo-when-using-keypathsforvaluesaffecting-key.html <http://www.cocoabuilder.com/archive/cocoa/239182-crash-in-kvo-when-using-keypathsforvaluesaffecting-key.html>
(Nearly 6 years ago, can you believe it?) I don’t know whether it’s the same problem, but in both cases the frameworks are internally creating an observation that’s the same as a code-created observation (apart from context). Apparently the removal code was unable to properly distinguish between the two observations, and that’s more or less what Sean reported.
_______________________________________________
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