Skip to content

Instantly share code, notes, and snippets.

@mschulkind
Created August 13, 2011 00:27
Show Gist options
  • Save mschulkind/1143324 to your computer and use it in GitHub Desktop.
Save mschulkind/1143324 to your computer and use it in GitHub Desktop.
async image loading
// imageView is a UIImageView
NSURL* imageNSURL = [NSURL URLWithString:value];
dispatch_async(
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
^{
NSData* imageData = [[NSData alloc] initWithContentsOfURL:imageNSURL];
dispatch_async(
dispatch_get_main_queue(),
^{
imageView.image = [UIImage imageWithData:imageData];
[imageData release];
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment