title: How to wait for another thread to complete before continuing with a segue?
body: <p>I have two UITableViewControllers and I am segueing between them, using a storyboard.</p>
  
  <p>In <code>prepareForSegue:sender:</code>, the first VC gets an NSArray from a web service and sets the model of the destination VC with the downloaded data. I put the downloading part into a <code>dispatch_queue_t</code> so it will run asynchronously and not block the UI thread. I want to tap a table cell, have the UIActivityIndicatorView start spinning, download the photos, and when the photos are downloaded, stop the spinner and continue with the segue.</p>
  
  <p>In the first UITableViewController I have a <code>prepareForSegue:sender:</code> method:</p>
  
  <pre><code>- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
  {
      if ([segue.identifier isEqualToString:@"SelectPlace"]) {
          NSIndexPath *indexPath = [self.tableView indexPathForCell:sender];
  
          UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc]
                                              initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
          [spinner startAnimating];
          self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:spinner];
  
          __block NSArray *photos = [[NSMutableArray alloc] init];
          dispatch_queue_t downloadQueue = dispatch_queue_create("flickr download", NULL);
          dispatch_async(downloadQueue, ^{
              photos = [FlickrFetcher photosInPlace:[self.places objectAtIndex:indexPath.row] maxResults:50];
          });
          dispatch_release(downloadQueue);
          [spinner stopAnimating];
          [segue.destinationViewController setPhotos:photos withTitle:[[sender textLabel] text]];
      }
  
  }
  </code></pre>
  
  <p>Right now it is immediately performing the segue without showing the spinner or waiting for the download to complete.</p>
  
  <p><strong>How can I asynchronously download the data to prepare the destination view without blocking the main thread, but also without immediately segueing?</strong></p>