Implementing async notifications
Implementing async notifications
- Subject: Implementing async notifications
- From: Jon Sigman <email@hidden>
- Date: Fri, 10 Dec 2010 11:50:44 -0800 (PST)
I have a Cocoa app that uses a dedicated thread to receive messages, and I would
like that thread to post those messages as notifications so they can be
processed asynchronously, outside my receiving loop (but not on the main
thread).
Looking at NSNotificationQueue, I'm totally confused by it. I searched for a
code example of how it interfaces with NSNotificationCenter but couldn't find
one complete enough to implement.
So... since notifications are executed on the thread that enqueued the
notification, would it be okay to do the following within my receiving loop:
1. Receive a message
2. Package the message into a NSData object
3. Use -performSelectorInBackground:withObject: to invoke a method that posts a
notification to the default notification center.
4. The notification is processed asynchronously in the background thread, and
exits.
Would this approach work to achieve async notification processing?
-Jon
_______________________________________________
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