• 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: NSNotificationCenter : multiple messages sent to the same observer?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSNotificationCenter : multiple messages sent to the same observer?


  • Subject: Re: NSNotificationCenter : multiple messages sent to the same observer?
  • From: Bill Bumgarner <email@hidden>
  • Date: Sun, 22 Feb 2009 09:39:37 -0800

On Feb 22, 2009, at 8:59 AM, Iceberg-Dev wrote:
On Feb 22, 2009, at 1:37 AM, Michael Ash wrote:
On Sat, Feb 21, 2009 at 6:06 PM, Iceberg-Dev <email@hidden> wrote:
I just discovered something recently. If you register an observer with the
same name/object/selector twice, you get the notification twice when you
post it.


Isn't the NSNotificationCenter supposed to prevent this?

Why, is there some place in the documentation where it says that?

There isn't. But it would make sense in 99% of cases.

Actually, the behavior is documented in the Cocoa Notifications programming topic:
It is possible for an observer to register to receive more than one message for the same notification. In such a case, the observer will receive all messages it is registered to receive for the notification, but the order in which it receives them cannot be determined.

The current behavior makes it possible to implement architectures where a client could take "more action" for any given notification by registering more than once. Not supporting this pattern would make such a pattern significantly more inconvenient to implement.

As well, any kind of a coalescing in the notification center is going to increase the complexity/overhead of the observer and, in particularly, might likely impact notification delivery speed (or, alternatively, require the notification center to use a bunch more memory to differentiate between "set of registered observers" and "list of observers that I actually deliver stuff to").

b.bum
_______________________________________________

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: NSNotificationCenter : multiple messages sent to the same observer?
      • From: Iceberg-Dev <email@hidden>
References: 
 >NSNotificationCenter : multiple messages sent to the same observer? (From: Iceberg-Dev <email@hidden>)
 >Re: NSNotificationCenter : multiple messages sent to the same observer? (From: Michael Ash <email@hidden>)
 >Re: NSNotificationCenter : multiple messages sent to the same observer? (From: Iceberg-Dev <email@hidden>)

  • Prev by Date: RE: Question on threads running in my Foundation tool
  • Next by Date: Re: How to get the "white shadow" effect when drawing NSStrings?
  • Previous by thread: Re: NSNotificationCenter : multiple messages sent to the same observer?
  • Next by thread: Re: NSNotificationCenter : multiple messages sent to the same observer?
  • Index(es):
    • Date
    • Thread