- (UITableViewCell *)tableView:(UITableView *)tableView
   cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
   static NSString *CellIdentifier = @"Cell";

   UITableViewCell *cell = 
      [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

   if (cell == nil) {
      cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 
                                     reuseIdentifier:CellIdentifier] autorelease];
   } else {
      for (UIView *view in cell.contentView.subviews){
         [view removeFromSuperview];
      }
   }

   __block UIImage *image = 
      [[results objectAtIndex:indexPath.row] objectForKey:@"image"];

   if (!image) {
      void (^imageLoadingBlock)(void);

      UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc]
         initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];

      spinner.autoresizingMask = 
         UIViewAutoresizingFlexibleLeftMargin |
         UIViewAutoresizingFlexibleRightMargin | 
         UIViewAutoresizingFlexibleTopMargin | 
         UIViewAutoresizingFlexibleBottomMargin;

      spinner.contentMode = UIViewContentModeCenter;
      spinner.center = cell.contentView.center;
      [spinner startAnimating];

      [cell.contentView addSubview:spinner];
      [spinner release];

      imageLoadingBlock = ^{
         image = [UIImage imageWithData:
            [NSData dataWithContentsOfURL:
               [NSURL URLWithString:
                  [[results objectAtIndex:indexPath.row] 
                     objectForKey:@"unescapedUrl"]]]];
         [image retain];

         dispatch_async(dispatch_get_main_queue(),^{
            [[results objectAtIndex:indexPath.row]
               setValue:image forKey:@"image"];
            [image release];
            [spinner stopAnimating];
            // Odświeżenie danego rekordu.
            [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
               withRowAnimation:NO];
         });
      };

      dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
         imageLoadingBlock);
   } else {
      UIImageView *imageView = [[[UIImageView alloc] initWithImage:image] autorelease];

      imageView.contentMode = UIViewContentModeScaleAspectFit;
      imageView.autoresizingMask = 
         UIViewAutoresizingFlexibleWidth |
         UIViewAutoresizingFlexibleHeight;
      imageView.frame = cell.contentView.frame;

      [cell.contentView addSubview:imageView];
   }
   return cell;
}
