Skip to content

Commit

Permalink
Replace usage of imageWithData: with imageWithContentsOfFile:
Browse files Browse the repository at this point in the history
  • Loading branch information
ejensen committed Jun 9, 2016
1 parent 7de82b0 commit 1fb3ffc
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions AsyncDisplayKit/ASNetworkImageNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -457,26 +457,27 @@ - (void)_lazilyLoadImageIfNecessary
} 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.
NSData *data = [NSData dataWithContentsOfURL:_URL];
if (data == nil) {
UIImage *nonAnimatedImage = [UIImage imageWithContentsOfFile:_URL.path];
if (nonAnimatedImage == nil) {
// 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 != nil) {
data = [NSData dataWithContentsOfFile:filename];
nonAnimatedImage = [UIImage imageWithContentsOfFile:filename];
}
}

// If the file may be an animated gif and then created an animated image.
id<ASAnimatedImageProtocol> animatedImage = nil;
if (_downloaderImplementsAnimatedImage && data != nil && [_URL.pathExtension isEqualToString:@"gif"]) {
if (_downloaderImplementsAnimatedImage && [_URL.pathExtension isEqualToString:@"gif"]) {
NSData *data = [NSData dataWithContentsOfURL:_URL];
animatedImage = [_downloader animatedImageWithData:data];
}

if (animatedImage != nil) {
self.animatedImage = animatedImage;
} else {
self.image = [UIImage imageWithData:data];
self.image = nonAnimatedImage;
}
}

Expand Down

0 comments on commit 1fb3ffc

Please sign in to comment.