title: Can I update the UI during PDF creation?
body: <p>I'm trying to create a multipage PDF for the QuickLook framework to print but am unable to update the UI while creating it (I want the user to get a countdown of how many pages remain). The following code is a simplified version of what I'm trying to do with the thread sleep stuff standing in for code which takes a while to render.</p>
  
  <pre><code>- (void) testPDF
  {
      CGRect pageSize = CGRectMake(0.0f, 0.0f, 595.28, 841.89);
  
      UIGraphicsBeginPDFContextToFile([self filePath], pageSize, nil);
      {
          UIGraphicsBeginPDFPage();
  
          for( int y = 0; y &lt; 5; y++ )    {
              self.pageLabel.text = [NSString stringWithFormat:@"%d", y];
  
              [[UIColor grayColor] set];
              [@"test string" drawAtPoint:CGPointMake(0, y*20) withFont:[UIFont systemFontOfSize:15]];
  
              NSDate *future = [NSDate dateWithTimeIntervalSinceNow: 1.0];
              [NSThread sleepUntilDate:future];
          }
      }
      UIGraphicsEndPDFContext();
  }
  </code></pre>
  
  <p>As it stands my code renders the PDF but doesn't update the IBOutlet 'pageLabel', any help would be greatly appreciated.</p>