• 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
Removing Observers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Removing Observers


  • Subject: Removing Observers
  • From: Ryan Brown <email@hidden>
  • Date: Mon, 18 Aug 2008 14:23:38 -0400

What is the best way to remove a KVO observer if you aren't sure if the object already has an observer registered? Currently I'm catching the exception raised for an unregistered observer using something like:

@try { [object removeObserver:observerObject forKeyPath:keyPath]; }
@catch(NSException *exception) {}

This seems like a fairly kludgey way to do it though, and apparently the exception isn't raised on 10.4 (it instead either crashes or does nothing).

Best,
Ryan
_______________________________________________

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


  • Follow-Ups:
    • Re: Removing Observers
      • From: Graham Cox <email@hidden>
  • Prev by Date: Re: Right place to unobserve notifications in a document
  • Next by Date: Re: NSString Question
  • Previous by thread: Re: Audio Queue Services example?
  • Next by thread: Re: Removing Observers
  • Index(es):
    • Date
    • Thread