• 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 tothe same observer?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSNotificationCenter : multiple messages sent tothe same observer?


  • Subject: Re: NSNotificationCenter : multiple messages sent tothe same observer?
  • From: "Paul Sanders" <email@hidden>
  • Date: Sun, 22 Feb 2009 18:56:16 -0000

I think the second call to addObserver should fail, perhaps even throw an
exception.  It's almost certainly a programming error.  Just my $0.02 worth.

But it's probably too late to change the behaviour now, if it might break
somebody's app.

----- Original Message -----
From: "Iceberg-Dev" <email@hidden>
To: "Cocoa-dev List" <email@hidden>
Sent: Sunday, February 22, 2009 6:23 PM
Subject: Re: NSNotificationCenter : multiple messages sent tothe same
observer?



On Feb 22, 2009, at 7:06 PM, Bill Bumgarner wrote:

> On Feb 22, 2009, at 9:59 AM, Iceberg-Dev wrote:
>> [...]
>>> 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").
>>
>> I think it would just require to make the search once on
>> registration, not every time a notification is sent.
>
> Assuming that your statement is made in light of trying to avoid
> the bloat I alluded to in the previous paragraph, this would lead
> to some very surprising behavior.
>
> Imagine this sequence of calls...
>
> - (void)addObserver:self selector:(SEL)aSelector
> name:BobsYourUncleNotification object:(id)anObject;
> - (void)addObserver:self selector:(SEL)aSelector
> name:BobsYourUncleNotification object:(id)anObject;
> - (void)removeObserver:self name:BobsYourUncleNotification object:
> (id)anObject;
>
> If the notification center coalesced observers on registration, the
> above would mean that the notification would no longer be sent.

If anObject is the same object in the 3 calls, this is probably
already the case if I am to believe the documentation. Which is the
behavior I would expect/wish for.
_______________________________________________

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

_______________________________________________

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

  • Prev by Date: Re: Unexpected mouse-handling behaviour
  • Next by Date: Re: Small animation inside NSCell (progress bar)
  • 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