• 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: Receiver type for instance message is a forward declaration
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Receiver type for instance message is a forward declaration


  • Subject: Re: Receiver type for instance message is a forward declaration
  • From: Quincey Morris <email@hidden>
  • Date: Tue, 10 May 2016 16:20:59 -0700
  • Feedback-id: 167118m:167118agrif8a:167118sbz7l15ghZ:SMTPCORP

On May 10, 2016, at 16:11 , Jens Alfke <email@hidden> wrote:
>
> what goes wrong if it’s NULL

If anything else uses NULL, then your observation is not uniquely identified, which means that:

— you might respond to a notification registered by an ancestor class of your observer instance, breaking some of its functionality;

— *removing* the observer can remove the wrong observation.

Since there are believed to be a few cases where Cocoa registers its own observations in classes that apps will actually subclass, and Cocoa uses NULL for such contexts, apps should avoid NULL. In addition, for uniqueness within the app’s code, it’s easiest to use something other than NULL that’s known to be unique to the current compilation unit (usually).

This is also why a version of ‘removeObserver’ that takes a ‘context’ parameter was retrofitted, several OS X versions ago.


_______________________________________________

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: 
 >Receiver type for instance message is a forward declaration (From: Carl Hoefs <email@hidden>)
 >Re: Receiver type for instance message is a forward declaration (From: Quincey Morris <email@hidden>)
 >Re: Receiver type for instance message is a forward declaration (From: Carl Hoefs <email@hidden>)
 >Re: Receiver type for instance message is a forward declaration (From: Carl Hoefs <email@hidden>)
 >Re: Receiver type for instance message is a forward declaration (From: Quincey Morris <email@hidden>)
 >Re: Receiver type for instance message is a forward declaration (From: Carl Hoefs <email@hidden>)
 >Re: Receiver type for instance message is a forward declaration (From: Quincey Morris <email@hidden>)
 >Re: Receiver type for instance message is a forward declaration (From: Carl Hoefs <email@hidden>)
 >Re: Receiver type for instance message is a forward declaration (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: Receiver type for instance message is a forward declaration
  • Next by Date: Re: Receiver type for instance message is a forward declaration
  • Previous by thread: Re: Receiver type for instance message is a forward declaration
  • Next by thread: Re: Receiver type for instance message is a forward declaration
  • Index(es):
    • Date
    • Thread