• 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
Implementing async notifications
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Implementing async notifications
      • From: Sixten Otto <email@hidden>
  • Prev by Date: iOS: Monospaced fonts aren't?
  • Next by Date: Re: iOS: Monospaced fonts aren't?
  • Previous by thread: Re: iOS: Monospaced fonts aren't?
  • Next by thread: Re: Implementing async notifications
  • Index(es):
    • Date
    • Thread