Skip to content

Instantly share code, notes, and snippets.

@blitzvb
Created January 3, 2015 23:21
Show Gist options
  • Save blitzvb/87c8238f23c6de07e4d5 to your computer and use it in GitHub Desktop.
Save blitzvb/87c8238f23c6de07e4d5 to your computer and use it in GitHub Desktop.
load image in background thread
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^(void) {
NSData *data0 = [NSData dataWithContentsOfURL:someURL];
UIImage *image = [UIImage imageWithData:data0];
dispatch_sync(dispatch_get_main_queue(), ^(void) {
UIImageView* imageView = (UIImageView*)[cell viewWithTag:100];
imageView.image = image;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment