Permalink
Browse files

Fixed a subtle ordering bug.

  • Loading branch information...
1 parent c1e5da6 commit e6ceb941dddf3f17d8ed3d340704e9fe6fb1d2d5 Patrick Hughes committed Aug 31, 2012
Showing with 9 additions and 4 deletions.
  1. +9 −4 UIImageView+ZSAssetManagerAdditions.m
@@ -16,14 +16,14 @@ @implementation UIImageView (ZSAssetManagerAdditions)
- (void)setImageWithURL:(NSURL *)url
{
+ objc_setAssociatedObject(self, assetManagerImageURLKey, url, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+ self.image = nil;
+
if (!url) {
DLog(@"nil url passed");
- objc_removeAssociatedObjects(self);
return;
}
- objc_setAssociatedObject(self, assetManagerImageURLKey, url, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
-
__weak UIImageView *blockSelf = self;
[[ZSAssetManager sharedAssetManager] fetchImageForURL:url withCompletionBlock:^(NSURL *fetchedUrl, UIImage *image) {
@@ -37,8 +37,13 @@ - (void)setImageWithURL:(NSURL *)url
- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholderImage
{
- self.image = placeholderImage;
+ // Request the image from the asset manager.
[self setImageWithURL:url];
+
+ // If the asset manager has it, don't set the placeholder.
+ if (!self.image) {
+ self.image = placeholderImage;
+ }
}
@end

0 comments on commit e6ceb94

Please sign in to comment.