diff options
author | Vitaly Takmazov | 2013-11-05 22:25:33 +0400 |
---|---|---|
committer | Vitaly Takmazov | 2013-11-05 22:25:33 +0400 |
commit | c3750f7891ab73ed4c4bfa8ddc59969fe77b0d9e (patch) | |
tree | 583f068ea0da76667b3d96b45f6c1e8fc5d1f44e /Juick/UIImage+Helpers.m | |
parent | a795a089148f73389f1e35430ed94a9aec9156e7 (diff) |
load avatars async
Diffstat (limited to 'Juick/UIImage+Helpers.m')
-rw-r--r-- | Juick/UIImage+Helpers.m | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Juick/UIImage+Helpers.m b/Juick/UIImage+Helpers.m new file mode 100644 index 0000000..a4ae8e4 --- /dev/null +++ b/Juick/UIImage+Helpers.m @@ -0,0 +1,24 @@ +// +// UIImage+Helpers.m +// Juick +// +// Created by Vitaly Takmazov on 05.11.13. +// Copyright (c) 2013 com.juick. All rights reserved. +// + +#import "UIImage+Helpers.h" + +@implementation UIImage (Helpers) + ++ (void) loadFromURL: (NSURL*) url callback:(void (^)(UIImage *image))callback { + dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul); + dispatch_async(queue, ^{ + NSData * imageData = [NSData dataWithContentsOfURL:url]; + dispatch_async(dispatch_get_main_queue(), ^{ + UIImage *image = [UIImage imageWithData:imageData]; + callback(image); + }); + }); +} + +@end |