title: How to send selectors or blocks to an NSRunLoop to perform?
body: <p>I need to guarantee that the same thread performs various actions at arbitrary times. First the thread needs to initialize a library, then I want the thread to sleep until work needs to be done and upon user input, I need to be able to pass selectors or blocks for execution.</p>
  
  <p><strong>How can I setup an NSRunLoop to sleep after initialization? After which, how do I signal the run loop to wake up and do something?</strong></p>
  
  <p>I've tried reading the Threading Programming Guide for iOS, but I'd like to avoid setting up classes as custom input classes and use something more lightweight like <code>performSelector:onThread:</code></p>
  
  <p>Can I set a timer to fire forever from now so the run loop doesn't end?</p>
  
  <p>Here's essentially what I want in pseudo-code:</p>
  
  <pre><code>// Initialization Code...
  
  do {
      sleepUntilSignaled();
      doWorkSentToThisThread();
  while (!done);
  </code></pre>
  
  <p>Where I send the work to do as a <code>performSelector:onThread:</code> message. It would be even better if I could send the run loop a block like: <code>^{[someObj message]; [otherObj otherMsg];}</code> but I'd be happy with <code>performSelector</code> since I'm pretty sure that's possible without much extra coding.</p>
  
  <p>Thanks!</p>