Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions AsyncDisplayKit/ASNetworkImageNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ NS_ASSUME_NONNULL_BEGIN

@optional

/**
* Notification that the image node failed to download the image.
*
* @param imageNode The sender.
* @param error The error with details.
*
* @discussion Called on a background queue.
*/
- (void)imageNode:(ASNetworkImageNode *)imageNode didFailWithError:(NSError *)error;

/**
* Notification that the image node finished decoding an image.
*
Expand Down
11 changes: 7 additions & 4 deletions AsyncDisplayKit/ASNetworkImageNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,14 @@ - (void)_cancelImageDownload
_cacheUUID = nil;
}

- (void)_downloadImageWithCompletion:(void (^)(CGImageRef))finished
- (void)_downloadImageWithCompletion:(void (^)(CGImageRef, NSError*))finished
{
_imageDownload = [_downloader downloadImageWithURL:_URL
callbackQueue:dispatch_get_main_queue()
downloadProgressBlock:NULL
completion:^(CGImageRef responseImage, NSError *error) {
if (finished != NULL) {
finished(responseImage);
finished(responseImage, error);
}
}];
}
Expand Down Expand Up @@ -210,7 +210,7 @@ - (void)_lazilyLoadImageIfNecessary
}
} else {
__weak __typeof__(self) weakSelf = self;
void (^finished)(CGImageRef) = ^(CGImageRef responseImage) {
void (^finished)(CGImageRef, NSError *) = ^(CGImageRef responseImage, NSError *error) {
__typeof__(self) strongSelf = weakSelf;
if (strongSelf == nil) {
return;
Expand All @@ -232,6 +232,9 @@ - (void)_lazilyLoadImageIfNecessary
if (responseImage != NULL) {
[strongSelf->_delegate imageNode:strongSelf didLoadImage:strongSelf.image];
}
else if (error && [strongSelf->_delegate respondsToSelector:@selector(imageNode:didFailWithError:)]) {
[strongSelf->_delegate imageNode:strongSelf didFailWithError:error];
}
};

if (_cache != nil) {
Expand All @@ -247,7 +250,7 @@ - (void)_lazilyLoadImageIfNecessary
if (image == NULL && _downloader != nil) {
[self _downloadImageWithCompletion:finished];
} else {
finished(image);
finished(image, NULL);
}
};

Expand Down