Skip to content

Instantly share code, notes, and snippets.

@jakemoore
Created January 28, 2012 07:40
Show Gist options
  • Save jakemoore/1693266 to your computer and use it in GitHub Desktop.
Save jakemoore/1693266 to your computer and use it in GitHub Desktop.
- (UIImage *)imageForView:(UIImageView *)imageView atRow:(int)row inTabelView:(UITableView *)tableView
{
int type = TYPE_FIRST;
if (tableView == self.secondInspectionsTV) type = TYPE_SECOND;
__block UIImage *image = nil;
if (type == TYPE_FIRST) image = [self.firstImages objectForKey:[NSNumber numberWithInt:row]];
else image = [self.secondImages objectForKey:[NSNumber numberWithInt:row]];
if (image != nil) return image;
dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
Inspection *inspection = nil;
if (type == TYPE_FIRST) inspection = [self.firstInspections objectAtIndex:row];
else inspection = [self.secondInspections objectAtIndex:row];
UIImage *image = [UIImage imageWithContentsOfFile:inspection.path];
if (image != nil) {
image = [ReviewRentalViewController imageWithImage:image scaledToSize:CGSizeMake(imageView.frame.size.width, imageView.frame.size.height)];
}
dispatch_async( dispatch_get_main_queue(), ^{
if (image != nil) [imageView setImage:image];
});
});
return nil;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment