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" <dev.iceb...@gmail.com> To: "Cocoa-dev List" <cocoa-dev@lists.apple.com> 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 (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/p.sanders%40dsl.pipex.com This email sent to p.sand...@dsl.pipex.com _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com