Skip to content

Instantly share code, notes, and snippets.

@pratikshabhisikar
Created July 26, 2012 09:14
Show Gist options
  • Save pratikshabhisikar/3181152 to your computer and use it in GitHub Desktop.
Save pratikshabhisikar/3181152 to your computer and use it in GitHub Desktop.
-(void) reloadTableCellsAtIndexPaths:(NSArray *) indexPaths {
NSArray *visibleTableCells = [self.tableView indexPathsForVisibleRows];
[indexPaths enumerateObjectsWithOptions:NSEnumerationConcurrent usingBlock:^(id obj, NSUInteger idx, BOOL *stop){
BOOL isVisible = [visibleTableCells containsObject:obj];
if (isVisible) {
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:obj] withRowAnimation:UITableViewRowAnimationFade];
}
}];
}
#pragma mark - PBDownloadImageOperation delegates
-(void) imageDownloadOperation:(PBImageDownloadOperation *) imageDownloadOperation didDownloadImageData:(NSData *) imageData {
// Cache the image.
[imageCache cacheObject:imageData forKey:imageDownloadOperation.imageURL];
[self performSelectorOnMainThread:@selector(reloadTableCellsAtIndexPaths:) withObject:[NSArray arrayWithObject:imageDownloadOperation.imageIndexPath] waitUntilDone:NO];
}
-(void) imageDownloadOperation:(PBImageDownloadOperation *)imageDownloadOperation didFailWithError:(NSError *) error {
// Display error and/or optionally retry the image downloading...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment