Skip to content

Commit

Permalink
add BOOL if cache was used to load image
Browse files Browse the repository at this point in the history
This is useful for animation - if function directly returns, there's no need to animate the new image
  • Loading branch information
steipete committed Sep 12, 2011
1 parent 2fbc30d commit 1ec54e2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion AFNetworking/UIImageView+AFNetworking.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions AFNetworking/UIImageView+AFNetworking.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -102,15 +102,15 @@ - (void)setImageWithURL:(NSURL *)url
self.image = cachedImage;

if (block) {
block(cachedImage);
block(cachedImage, YES);
}
} else {
self.image = placeholderImage;

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]]) {
Expand Down

0 comments on commit 1ec54e2

Please sign in to comment.