Re: removeObserver:forKeyPath: when already removed
Re: removeObserver:forKeyPath: when already removed
- Subject: Re: removeObserver:forKeyPath: when already removed
- From: Shawn Erickson <email@hidden>
- Date: Wed, 11 Nov 2009 17:11:41 -0800
On Wed, Nov 11, 2009 at 2:35 PM, James Walker <email@hidden> wrote:
> I had a situation where removeObserver:forKeyPath: was called twice for the
> same receiver (an NSUserDefaultsController), the same observer, and the same
> key path. It threw an NSRangeException. But the KVO docs don't say
> anything about removeObserver:forKeyPath: throwing an exception. Should
> this be considered a documentation bug, or is it a bug that
> -[NSUserDefaultsController removeObserver:forKeyPath:] threw an exception,
> or should I have just expected this due to some general principle?
Yeah this is currently what happens (wasn't always this way IIRC) and
I don't think I have ever seen it documented (not that I expect it to
be). IMHO I wish it didn't throw an exception since it puts extra work
on developers to track if they are currently observing a keypath
before attempting to remove that observation. It is nice to have as a
debugging aid but it does make some simpler code patterns impossible.
-Shawn
_______________________________________________
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