title: Stop NSRunLoop On Keypress
body: <p>I'm writing a command line foundation tool in Mac OS X and would like the tool to quit on a keypress such as 'q'.  The code is launching an asynchronous request for retrieving data from a remote server.  This necessitates the NSRunLoop.  At least that's what I understand I need to do.  </p>
  
  <p>Can someone tell me how to stop the runloop on the specific keypress?</p>
  
  <p>Below is the code snippet.</p>
  
  <pre><code>int main (int argc, const char * argv[]) {
  
  BOOL keepRunning = YES;
  NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
  
  Requestor *myRequestor = [[Requestor alloc] init];
  [myRequestor GetData];
  
  NSRunLoop *runLoop;
  runLoop = [NSRunLoop currentRunLoop];
  
  while (keepRunning &amp;&amp; [runLoop runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]);
  
  [pool drain];
  return 0;
  }
  </code></pre>
  
  <p>Thank you!</p>