diff --git a/AsyncDisplayKit/ASMultiplexImageNode.mm b/AsyncDisplayKit/ASMultiplexImageNode.mm index 0bc9c6e8f8..d32d3be061 100644 --- a/AsyncDisplayKit/ASMultiplexImageNode.mm +++ b/AsyncDisplayKit/ASMultiplexImageNode.mm @@ -139,6 +139,13 @@ typedef void(^ASMultiplexImageLoadCompletionBlock)(UIImage *image, id imageIdent */ - (void)_downloadImageWithIdentifier:(id)imageIdentifier URL:(NSURL *)imageURL completion:(void (^)(UIImage *image, NSError *error))completionBlock; +/** + @abstract Returns a Boolean value indicating whether the downloaded image should be removed when clearing fetched data + @discussion Downloaded image data should only be cleared out if a cache is present + @return YES if an image cache is available; otherwise, NO. + */ +- (BOOL)_shouldClearFetchedImageData; + @end @implementation ASMultiplexImageNode @@ -173,11 +180,15 @@ typedef void(^ASMultiplexImageLoadCompletionBlock)(UIImage *image, id imageIdent } } -- (void)displayWillStart +- (void)clearFetchedData { - [super displayWillStart]; - - [self fetchData]; + [super clearFetchedData]; + + if ([self _shouldClearFetchedImageData]) { + // setting this to nil makes the node fetch images the next time its display starts + _loadedImageIdentifier = nil; + self.image = nil; + } } - (void)fetchData @@ -626,4 +637,8 @@ typedef void(^ASMultiplexImageLoadCompletionBlock)(UIImage *image, id imageIdent [self _loadNextImage]; } +- (BOOL)_shouldClearFetchedImageData { + return _cache != nil; +} + @end