From 47115e2593e5596abd7a9c9831474458a99abe2a Mon Sep 17 00:00:00 2001 From: liushuaikobe Date: Mon, 18 Jan 2016 16:29:28 +0800 Subject: [PATCH] If the sd_imageURL of the UIImageView or UIButton is nil, won't create a NSError Instance --- SDWebImage/UIButton+WebCache.m | 2 +- SDWebImage/UIImageView+WebCache.m | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/SDWebImage/UIButton+WebCache.m b/SDWebImage/UIButton+WebCache.m index 3df3804f..ce2175d2 100644 --- a/SDWebImage/UIButton+WebCache.m +++ b/SDWebImage/UIButton+WebCache.m @@ -57,8 +57,8 @@ static char imageURLStorageKey; [self.imageURLStorage removeObjectForKey:@(state)]; dispatch_main_async_safe(^{ - NSError *error = [NSError errorWithDomain:SDWebImageErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; if (completedBlock) { + NSError *error = [NSError errorWithDomain:SDWebImageErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; completedBlock(nil, error, SDImageCacheTypeNone, url); } }); diff --git a/SDWebImage/UIImageView+WebCache.m b/SDWebImage/UIImageView+WebCache.m index ec0d2e98..14f425cc 100644 --- a/SDWebImage/UIImageView+WebCache.m +++ b/SDWebImage/UIImageView+WebCache.m @@ -87,8 +87,8 @@ static char TAG_ACTIVITY_SHOW; } else { dispatch_main_async_safe(^{ [self removeActivityIndicator]; - NSError *error = [NSError errorWithDomain:SDWebImageErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; if (completedBlock) { + NSError *error = [NSError errorWithDomain:SDWebImageErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; completedBlock(nil, error, SDImageCacheTypeNone, url); } });