diff --git a/AsyncDisplayKit/ASNetworkImageNode.mm b/AsyncDisplayKit/ASNetworkImageNode.mm old mode 100644 new mode 100755 index c1437ef814..cbba35af9c --- a/AsyncDisplayKit/ASNetworkImageNode.mm +++ b/AsyncDisplayKit/ASNetworkImageNode.mm @@ -188,14 +188,23 @@ ASDN::MutexLocker l(_lock); dispatch_async(dispatch_get_main_queue(), ^{ - _imageLoaded = YES; - if (self.shouldCacheImage) { - self.image = [UIImage imageNamed:_URL.path]; + self.image = [UIImage imageNamed:_URL.path.lastPathComponent]; } else { + // First try to load the path directly, for efficiency assuming a developer who + // doesn't want caching is trying to be as minimal as possible. self.image = [UIImage imageWithContentsOfFile:_URL.path]; + if (!self.image) { + // If we couldn't find it, execute an -imageNamed:-like search so we can find resources even if the + // extension is not provided in the path. This allows the same path to work regardless of shouldCacheImage. + NSString *filename = [[NSBundle mainBundle] pathForResource:_URL.path.lastPathComponent ofType:nil]; + if (filename) { + self.image = [UIImage imageWithContentsOfFile:filename]; + } + } } - + + _imageLoaded = YES; [_delegate imageNode:self didLoadImage:self.image]; }); }