Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

Commit e429d80

Browse files
maickigarrettmoon
authored andcommitted
Some further improvements
1 parent 0859542 commit e429d80

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

AsyncDisplayKit/ASMultiplexImageNode.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ - (void)didExitVisibleState
328328

329329
- (void)setImage:(UIImage *)image
330330
{
331-
ASDisplayNodeAssert(NO, @"Setting the image directly to an ASMultiplexImageNode is not allowed.");
331+
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");
332332
[self __setImage:image];
333333
}
334334

AsyncDisplayKit/ASNetworkImageNode.mm

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ - (void)dealloc
119119

120120
#pragma mark - Public methods -- must lock
121121

122+
/// 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
122123
- (void)setImage:(UIImage *)image
123124
{
124125
__instanceLock__.lock();
@@ -131,9 +132,17 @@ - (void)setImage:(UIImage *)image
131132
[self __setImage:image];
132133
}
133134

135+
/// Internal image setter that will first check if an image already was set externally and will return otherwise will set it
134136
- (void)_setImage:(UIImage *)image
135137
{
136138
__instanceLock__.lock();
139+
140+
#ifdef DEBUG
141+
if (_URL != nil) {
142+
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]));
143+
}
144+
#endif
145+
137146
if (_imageWasSetExternally) {
138147
__instanceLock__.unlock();
139148
return;
@@ -154,7 +163,7 @@ - (void)setURL:(NSURL *)URL resetToDefault:(BOOL)reset
154163

155164
#ifdef DEBUG
156165
if (_imageWasSetExternally) {
157-
NSLog(@"Image was already set via the .image property. Setting an image explicitly and setting an URL is not supported.");
166+
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]));
158167
}
159168
#endif
160169

AsyncDisplayKit/Private/ASImageNode+Private.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
* Set the image property of the ASImageNode. Subclasses like ASNetworkImageNode do not allow setting the
1919
* image property directly and throw an assertion. There still needs to be a way for subclasses of
2020
* ASNetworkImageNode to set the image.
21+
*
22+
* This is exposed to library subclasses, i.e. ASNetworkImageNode, ASMultiplexImageNode and ASVideoNode for setting
23+
* the image directly without going throug the setter of the superclass
2124
*/
2225
- (void)__setImage:(UIImage *)image;
2326

0 commit comments

Comments
 (0)