From 88ee3c6774f9a1f06f14daca24a7dffd1c522bf8 Mon Sep 17 00:00:00 2001 From: Bogdan Poplauschi Date: Thu, 19 Mar 2015 13:52:44 +0200 Subject: [PATCH] Replacing #1018 - avoid warning ": ImageIO: CGImageSourceCreateWithData data parameter is nil" if imageData is nil --- SDWebImage/SDWebImageDownloaderOperation.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/SDWebImage/SDWebImageDownloaderOperation.m b/SDWebImage/SDWebImageDownloaderOperation.m index 30f20d7..4bf2873 100644 --- a/SDWebImage/SDWebImageDownloaderOperation.m +++ b/SDWebImage/SDWebImageDownloaderOperation.m @@ -372,8 +372,7 @@ NSString *const SDWebImageDownloadFinishNotification = @"SDWebImageDownloadFinis if (completionBlock) { if (self.options & SDWebImageDownloaderIgnoreCachedResponse && responseFromCached) { completionBlock(nil, nil, nil, YES); - } - else { + } else if (self.imageData) { UIImage *image = [UIImage sd_imageWithData:self.imageData]; NSString *key = [[SDWebImageManager sharedManager] cacheKeyForURL:self.request.URL]; image = [self scaledImageForKey:key image:image]; @@ -390,6 +389,8 @@ NSString *const SDWebImageDownloadFinishNotification = @"SDWebImageDownloadFinis else { completionBlock(image, self.imageData, nil, YES); } + } else { + completionBlock(nil, nil, [NSError errorWithDomain:SDWebImageErrorDomain code:0 userInfo:@{NSLocalizedDescriptionKey : @"Image data is nil"}], YES); } } self.completionBlock = nil;