title: loading images in table using blocks - dispatch_async return value
body: <p>I have looked around on SO and the web and have not found a specific answer.</p>
  
  <p>Quite simply, I have a table loading images info from Flickr. I want to display a thumbnail of the image on the left side of each cell.</p>
  
  <p>In order to do this without blocking the main (UI) thread, I am using blocks:</p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {
    static NSString *CellIdentifier = @"top50places";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  
    //getting the selected row image 
    NSDictionary* currentImageDictionary=[self.topfifty objectAtIndex:indexPath.row];//topFifty is an array of image dictionaries
  
  
    //creating the download queue 
    dispatch_queue_t downloadQueue=dispatch_queue_create("thumbnailImage", NULL);
  
    dispatch_async(downloadQueue, ^{
  
      UIImage *downloadedThumbImage=[self getImage:currentImageDictionary] ;
  
      //Need to go back to the main thread since this is UI related
      dispatch_async(dispatch_get_main_queue(), ^{
  
          cell.imageView.image = downloadedThumbImage ;
  
      });
  
    });
  
    dispatch_release(downloadQueue);
  
    return cell;
  
  }
  </code></pre>
  
  <p>Now this is not going to work. Because returning the cell will likely happens before executing the block. But at the same time, I cannot return the cell within the main queue block because the block does not accept a return argument.</p>
  
  <p>I want to avoid creating a UITableViewCell subclass.</p>
  
  <p>Any simple answer using blocks?</p>
  
  <p>Thanks
  KMB</p>