Skip to content

Commit

Permalink
adding completion block to UIImageView category
Browse files Browse the repository at this point in the history
  • Loading branch information
atomkirk committed Dec 14, 2012
1 parent 73bfc6f commit 03fcf3d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions UIImageView+JMImageCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

- (void) setImageWithURL:(NSURL *)url;
- (void) setImageWithURL:(NSURL *)url placeholder:(UIImage *)placeholderImage;
- (void) setImageWithURL:(NSURL *)url placeholder:(UIImage *)placeholderImage completionBlock:(void (^)(UIImage *))completionBlock;
- (void) setImageWithURL:(NSURL *)url key:(NSString*)key placeholder:(UIImage *)placeholderImage;
- (void) setImageWithURL:(NSURL *)url key:(NSString*)key placeholder:(UIImage *)placeholderImage completionBlock:(void (^)(UIImage *image))completionBlock;

@end
8 changes: 8 additions & 0 deletions UIImageView+JMImageCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@ - (void) setImageWithURL:(NSURL *)url {
- (void) setImageWithURL:(NSURL *)url placeholder:(UIImage *)placeholderImage {
[self setImageWithURL:url key:nil placeholder:placeholderImage];
}
- (void) setImageWithURL:(NSURL *)url placeholder:(UIImage *)placeholderImage completionBlock:(void (^)(UIImage *))completionBlock {
[self setImageWithURL:url key:nil placeholder:placeholderImage completionBlock:completionBlock];
}
- (void) setImageWithURL:(NSURL *)url key:(NSString*)key placeholder:(UIImage *)placeholderImage {
[self setImageWithURL:url key:key placeholder:placeholderImage completionBlock:nil];
}
- (void) setImageWithURL:(NSURL *)url key:(NSString*)key placeholder:(UIImage *)placeholderImage completionBlock:(void (^)(UIImage *image))completionBlock {
self.jm_imageURL = url;
self.image = placeholderImage;

Expand Down Expand Up @@ -91,6 +97,8 @@ - (void) setImageWithURL:(NSURL *)url key:(NSString*)key placeholder:(UIImage *)

[safeSelf setNeedsLayout];
[safeSelf setNeedsDisplay];

if (completionBlock) completionBlock(image);
});
}
}];
Expand Down

0 comments on commit 03fcf3d

Please sign in to comment.