From dabb69d4619fe5c032498b24ceafbaa8b17105c3 Mon Sep 17 00:00:00 2001 From: Garrett Moon Date: Thu, 15 Dec 2016 12:01:18 -0800 Subject: [PATCH] Don't behave like an image node if URL is set. (#2774) After much discussion I think this is the correct behavior. It seems like it's much more likely to be the expected behavior but still enables you to use the network image node like an regular image node. --- AsyncDisplayKit/ASNetworkImageNode.h | 11 ++++++----- AsyncDisplayKit/ASNetworkImageNode.mm | 8 ++------ 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/AsyncDisplayKit/ASNetworkImageNode.h b/AsyncDisplayKit/ASNetworkImageNode.h index 149f12b99b..69be035fe4 100644 --- a/AsyncDisplayKit/ASNetworkImageNode.h +++ b/AsyncDisplayKit/ASNetworkImageNode.h @@ -52,11 +52,12 @@ NS_ASSUME_NONNULL_BEGIN /** * The image to display. * - * @discussion By setting an image to the image property the ASNetworkImageNode will act like a plain ASImageNode. - * As soon as the URL is set the ASNetworkImageNode will act like an ASNetworkImageNode and the image property - * will be managed internally. This means the image property will be cleared out and replaced by the placeholder - * () image while loading and the final image after the new image data was downloaded and processed. - * If you want to use a placholder image functionality use the defaultImage property instead. + * @discussion Setting an image to the image property of an ASNetworkImageNode will cause it to act like a plain + * ASImageNode if a URL is not set as well. As soon as the URL is set the ASNetworkImageNode will act like an + * ASNetworkImageNode and the image property will be managed internally. This means the image property will be cleared + * out and replaced by the placeholder () image while loading and the final image after the new image + * data was downloaded and processed. If you want to use a placholder image, use the defaultImage property + * instead. */ @property (nullable, nonatomic, strong) UIImage *image; diff --git a/AsyncDisplayKit/ASNetworkImageNode.mm b/AsyncDisplayKit/ASNetworkImageNode.mm index cad7b6e528..d5ee17ed1e 100755 --- a/AsyncDisplayKit/ASNetworkImageNode.mm +++ b/AsyncDisplayKit/ASNetworkImageNode.mm @@ -109,16 +109,12 @@ static const CGSize kMinReleaseImageOnBackgroundSize = {20.0, 20.0}; #pragma mark - Public methods -- must lock -/// Setter for public image property. It has the side effect to set an internal _imageWasSetExternally that prevents setting an image internally. Setting an image internally should happen with the _setImage: method +/// Setter for public image property. It has the side effect of setting an internal _imageWasSetExternally that prevents setting an image internally. Setting an image internally should happen with the _setImage: method - (void)setImage:(UIImage *)image { ASDN::MutexLocker l(__instanceLock__); - _imageWasSetExternally = (image != nil); - if (_imageWasSetExternally) { - [self _cancelDownloadAndClearImage]; - _URL = nil; - } + _imageWasSetExternally = (image != nil && _URL != nil); [self _setImage:image]; }