Re: Posting notifications
Re: Posting notifications
- Subject: Re: Posting notifications
- From: Jens Alfke <email@hidden>
- Date: Mon, 25 Jan 2010 09:05:42 -0800
On Jan 25, 2010, at 6:21 AM, McLaughlin, Michael P. wrote:
"A notification center delivers notifications to observers
synchronously. In
other words, when posting a notification, control does not return to
the
poster until all observers have received *and processed* the
notification."
[my emphasis]
Don't read too much into this — it's just regular function calls. When
you post the notification, NSNotification iterates over all the
observers and calls their notification methods one at a time, then
returns back to you.
This usually works fine. But if you're posting a notification and
don't want to be blocked right then, or if you want to coalesce
multiple posts of the same notification so observers are called only
once, have a look at NSNotificationQueue.
As an observer, if you find that you have a lot to do in response to a
notification and it's taking too long (or ends up making re-entrant
calls that confuse the calling code), you can change your observer
method to just call performSelector:afterDelay:, to defer the actual
processing.
—Jens_______________________________________________
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