• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: removeObserver:forKeyPath: when already removed
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >removeObserver:forKeyPath: when already removed (From: James Walker <email@hidden>)

  • Prev by Date: Re: iPhone CLLocation Accuracy?
  • Next by Date: Re: removeObserver:forKeyPath: when already removed
  • Previous by thread: Re: removeObserver:forKeyPath: when already removed
  • Next by thread: Re: Garbage collection and about windows
  • Index(es):
    • Date
    • Thread