Re: Calling -addObserver:forKeyPath:… more than once
Re: Calling -addObserver:forKeyPath:… more than once
- Subject: Re: Calling -addObserver:forKeyPath:… more than once
- From: Heath Borders <email@hidden>
- Date: Fri, 26 Aug 2011 09:09:19 -0500
You must call remove as many times as you call add. Otherwise,
subclasses and superclasses would interfere with each other's
observations.
-Heath Borders
email@hidden
Twitter: heathborders
http://heath-tech.blogspot.com
On Fri, Aug 26, 2011 at 4:34 AM, Rick Mann <email@hidden> wrote:
> Is -addObserver:forKeyPath:… idempotent? I called it multiple times with the same parameters, but called -removeObserver:forKeyPath: only once, and the object continued to receive KVO notifications.
>
> After adding code to ensure -addObserver:forKeyPath:… was only called once, -removeObserver:forKeyPath: seemed to work as expected.
>
> I couldn't find any clear indication in the docs or searching online, although I did find some things that indicate these APIs rather do suck.
>
> --
> Rick
>
> _______________________________________________
>
> 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
>
_______________________________________________
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