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: Tue, 10 Mar 2015 18:25:23 +0000
On Mar 10, 2015, at 10:50 , Sean McBride <email@hidden> wrote:
>
> Can anyone think of a sitation where using removeObserver:forKeyPath: works correctly, then modernizing the code to use removeObserver:forKeyPath:context: breaks things?
If something else is using a conflicting ‘removeObserver:forKeyPath:’, it might sorta work if all observers use it (because the total number of removals is equal to the number of observations, even if they remove each others’ observations), but fail if some try use ‘removeObserver:forKeyPath:context:’ on an observation that’s already been removed.
Also, a long time ago (Leopard-ish), there was a horrible bug where observations of (from?) the same thing could get mixed up so that attempting to remove one would actually remove the other. I doubt this was ever fixed — it was subtle.
So, all this, plus the odd backtrace that *might* indicate that the object controller is duplicating one of your observations, but without a context, and things are falling apart from there.
Unless something easy turns out to have been overlooked, this sounds TSI-worthy.
_______________________________________________
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