title: iOS: Processing UI events in NSRunLoop
body: <p>I'm working on an iPad app that needs to spawn a dialog mid-function for some user interaction. In order to wait for the dialog, I run an NSRunLoop, however, this is preventing events on the dialog from being processed. This is how I spawn the dialog:  </p>
  
  <pre><code>NSArray* listOfCompatibleTypes = [[NSArray alloc] initWithArray:[listOfCompatibleTypesAndSizesAsSet allObjects]];
  
  [secondaryImplantChooserDialog setModalPresentationStyle:UIModalPresentationFormSheet];
  [secondaryImplantChooserDialog setDefinesPresentationContext:YES];                
  [self presentViewController:secondaryImplantChooserDialog animated:NO completion:nil];
  </code></pre>
  
  <p>And the runloop is like this:  </p>
  
  <pre><code>NSRunLoop* runLoop = [NSRunLoop currentRunLoop];
  while (secondaryImplantChooserDialog.fDialogDone != YES)
  {
      [runLoop runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.01]];
  }
  </code></pre>
  
  <p>The dialog box has a popover that contains a tableview. When I comment out the runloop, the table view's didSelectRowAtIndexPath(…) method gets called. When the loop is active, however, that method doesn't get called until the dialog gets dismissed.</p>
  
  <p>I realize this isn't exactly an iOS-kosher design, so I should probably refactor it, but I was wondering if there was any way to process UI events while the runloop is active. </p>