From 1ec54e259578658be1308f22ae60ce6d270b735c Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 12 Sep 2011 17:36:20 +0200 Subject: [PATCH] add BOOL if cache was used to load image This is useful for animation - if function directly returns, there's no need to animate the new image --- AFNetworking/UIImageView+AFNetworking.h | 2 +- AFNetworking/UIImageView+AFNetworking.m | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/AFNetworking/UIImageView+AFNetworking.h b/AFNetworking/UIImageView+AFNetworking.h index 0b79875d0a..72a19eca02 100644 --- a/AFNetworking/UIImageView+AFNetworking.h +++ b/AFNetworking/UIImageView+AFNetworking.h @@ -39,6 +39,6 @@ placeholderImage:(UIImage *)placeholderImage imageSize:(CGSize)imageSize options:(AFImageRequestOptions)options - block:(void (^)(UIImage *image))block; + block:(void (^)(UIImage *image, BOOL cacheUsed))block; @end diff --git a/AFNetworking/UIImageView+AFNetworking.m b/AFNetworking/UIImageView+AFNetworking.m index 2fa7b96063..ebd483bd35 100644 --- a/AFNetworking/UIImageView+AFNetworking.m +++ b/AFNetworking/UIImageView+AFNetworking.m @@ -84,7 +84,7 @@ - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholderImage imageSize:(CGSize)imageSize options:(AFImageRequestOptions)options - block:(void (^)(UIImage *image))block + block:(void (^)(UIImage *image, BOOL cacheUsed))block { if (!url) { // stop loading image @@ -102,7 +102,7 @@ - (void)setImageWithURL:(NSURL *)url self.image = cachedImage; if (block) { - block(cachedImage); + block(cachedImage, YES); } } else { self.image = placeholderImage; @@ -110,7 +110,7 @@ - (void)setImageWithURL:(NSURL *)url self.imageRequestOperation = [AFImageRequestOperation operationWithRequest:request imageSize:imageSize options:options success:^(UIImage *image) { if (self.imageRequestOperation && ![self.imageRequestOperation isCancelled]) { if (block) { - block(image); + block(image, NO); } if ([[request URL] isEqual:[[self.imageRequestOperation request] URL]]) {