Skip to content

Instantly share code, notes, and snippets.

@nloko
Last active January 18, 2016 19:54
Show Gist options
  • Save nloko/6c62f3fb578c5d380ef4 to your computer and use it in GitHub Desktop.
Save nloko/6c62f3fb578c5d380ef4 to your computer and use it in GitHub Desktop.
self.text = self.event.text;
__weak id wself = self;
NSString *imageUrl = self.event.imageUrl;
self.image = nil;
self.overlay.image = nil;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
UIImage *image = [[wself downloadImage:imageUrl] scaleWithWidth:cellWidth];
UIImage *blurredImage = [image blurRect:overlayRect];
dispatch_async(dispatch_get_main_queue(), ^{
// skip if the cell’s event has changed
if (![imageUrl isEqualToString:wself.event.imageUrl]) {
return;
}
wself.overlay.image = blurredImage;
wself.image = image;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment