diff --git a/AsyncDisplayKit/ASMultiplexImageNode.mm b/AsyncDisplayKit/ASMultiplexImageNode.mm index 633562c873..a406050009 100644 --- a/AsyncDisplayKit/ASMultiplexImageNode.mm +++ b/AsyncDisplayKit/ASMultiplexImageNode.mm @@ -328,7 +328,7 @@ typedef void(^ASMultiplexImageLoadCompletionBlock)(UIImage *image, id imageIdent - (void)setImage:(UIImage *)image { - ASDisplayNodeAssert(NO, @"Setting the image directly to an ASMultiplexImageNode is not allowed."); + ASDisplayNodeAssert(NO, @"Setting the image directly on an ASMultiplexImageNode is unsafe. It will be cleared in didExitPreloadRange and will have no way to restore in didEnterPreloadRange"); [self __setImage:image]; } diff --git a/AsyncDisplayKit/ASNetworkImageNode.mm b/AsyncDisplayKit/ASNetworkImageNode.mm index 93ee34ac86..4f744e747c 100755 --- a/AsyncDisplayKit/ASNetworkImageNode.mm +++ b/AsyncDisplayKit/ASNetworkImageNode.mm @@ -119,6 +119,7 @@ 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 - (void)setImage:(UIImage *)image { __instanceLock__.lock(); @@ -131,9 +132,17 @@ static const CGSize kMinReleaseImageOnBackgroundSize = {20.0, 20.0}; [self __setImage:image]; } +/// Internal image setter that will first check if an image already was set externally and will return otherwise will set it - (void)_setImage:(UIImage *)image { __instanceLock__.lock(); + +#ifdef DEBUG + if (_URL != nil) { + NSLog(@"Setting the image directly on an %@ and setting an URL is not supported. If you decide to set an image direclty this node will work the same ways as an plain ASImageNode and not consider the image loaded via URL.", NSStringFromClass([self class])); + } +#endif + if (_imageWasSetExternally) { __instanceLock__.unlock(); return; @@ -154,7 +163,7 @@ static const CGSize kMinReleaseImageOnBackgroundSize = {20.0, 20.0}; #ifdef DEBUG if (_imageWasSetExternally) { - NSLog(@"Image was already set via the .image property. Setting an image explicitly and setting an URL is not supported."); + NSLog(@"Setting the image directly on an %@ and setting an URL is not supported. If you decide to set an image direclty this node will work the same ways as an plain ASImageNode and not consider the image loaded via URL.", NSStringFromClass([self class])); } #endif diff --git a/AsyncDisplayKit/Private/ASImageNode+Private.h b/AsyncDisplayKit/Private/ASImageNode+Private.h index 96271db52f..676af72ec0 100644 --- a/AsyncDisplayKit/Private/ASImageNode+Private.h +++ b/AsyncDisplayKit/Private/ASImageNode+Private.h @@ -18,6 +18,9 @@ * Set the image property of the ASImageNode. Subclasses like ASNetworkImageNode do not allow setting the * image property directly and throw an assertion. There still needs to be a way for subclasses of * ASNetworkImageNode to set the image. + * + * This is exposed to library subclasses, i.e. ASNetworkImageNode, ASMultiplexImageNode and ASVideoNode for setting + * the image directly without going throug the setter of the superclass */ - (void)__setImage:(UIImage *)image;