Skip to content

Commit 88ee3c6

Browse files
committed
Replacing #1018 - avoid warning "<Error>: ImageIO: CGImageSourceCreateWithData data parameter is nil" if imageData is nil
1 parent 6e94724 commit 88ee3c6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

SDWebImage/SDWebImageDownloaderOperation.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,7 @@ - (void)connectionDidFinishLoading:(NSURLConnection *)aConnection {
372372
if (completionBlock) {
373373
if (self.options & SDWebImageDownloaderIgnoreCachedResponse && responseFromCached) {
374374
completionBlock(nil, nil, nil, YES);
375-
}
376-
else {
375+
} else if (self.imageData) {
377376
UIImage *image = [UIImage sd_imageWithData:self.imageData];
378377
NSString *key = [[SDWebImageManager sharedManager] cacheKeyForURL:self.request.URL];
379378
image = [self scaledImageForKey:key image:image];
@@ -390,6 +389,8 @@ - (void)connectionDidFinishLoading:(NSURLConnection *)aConnection {
390389
else {
391390
completionBlock(image, self.imageData, nil, YES);
392391
}
392+
} else {
393+
completionBlock(nil, nil, [NSError errorWithDomain:SDWebImageErrorDomain code:0 userInfo:@{NSLocalizedDescriptionKey : @"Image data is nil"}], YES);
393394
}
394395
}
395396
self.completionBlock = nil;

0 commit comments

Comments
 (0)