Re: NSNotificationCenter : multiple messages sent to the same observer?
Re: NSNotificationCenter : multiple messages sent to the same observer?
- Subject: Re: NSNotificationCenter : multiple messages sent to the same observer?
- From: Iceberg-Dev <email@hidden>
- Date: Sun, 22 Feb 2009 19:23:38 +0100
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