title: Post a message to the main event loop of a Cocoa application?
body: <p>Let's say, in my GUI application (it is portable across OSX/iOS) I have multiple threads that may send notifications to the main application thread. The notifications should be handled within the same context where Cocoa's input events and redraw requests are handled. My goal is to reflect on the screen certain events that come from concurrent threads.</p>
  
  <p>On Windows there is PostMessage(), so what is its analog on OS X and iOS?</p>
  
  <p><code>dispatch_async()</code> seems to be a close candidate for this, however, the documentation says:</p>
  
  <blockquote>
    <p>The target queue determines whether the block is invoked serially or
    concurrently with respect to other blocks submitted to that same
    queue.</p>
  </blockquote>
  
  <p>which, honestly, says nothing but creates confusion. Plus it's not clear which of the message queues to use with <code>dispatch_async</code> so that the message is handled serially with respect to GUI events.</p>