Make a constant for the error domain
Showing
7 changed files
with
10 additions
and
6 deletions
@@ -62,7 +62,7 @@ static char imageURLKey; | @@ -62,7 +62,7 @@ static char imageURLKey; | ||
62 | [self sd_setImageLoadOperation:operation forKey:@"MKAnnotationViewImage"]; | 62 | [self sd_setImageLoadOperation:operation forKey:@"MKAnnotationViewImage"]; |
63 | } else { | 63 | } else { |
64 | dispatch_main_async_safe(^{ | 64 | dispatch_main_async_safe(^{ |
65 | - NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; | 65 | + NSError *error = [NSError errorWithDomain:SDWebImageErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; |
66 | if (completedBlock) { | 66 | if (completedBlock) { |
67 | completedBlock(nil, error, SDImageCacheTypeNone, url); | 67 | completedBlock(nil, error, SDImageCacheTypeNone, url); |
68 | } | 68 | } |
@@ -55,6 +55,8 @@ extern UIImage *SDScaledImageForKey(NSString *key, UIImage *image); | @@ -55,6 +55,8 @@ extern UIImage *SDScaledImageForKey(NSString *key, UIImage *image); | ||
55 | 55 | ||
56 | typedef void(^SDWebImageNoParamsBlock)(); | 56 | typedef void(^SDWebImageNoParamsBlock)(); |
57 | 57 | ||
58 | +extern NSString *const SDWebImageErrorDomain; | ||
59 | + | ||
58 | #define dispatch_main_sync_safe(block)\ | 60 | #define dispatch_main_sync_safe(block)\ |
59 | if ([NSThread isMainThread]) {\ | 61 | if ([NSThread isMainThread]) {\ |
60 | block();\ | 62 | block();\ |
@@ -43,3 +43,5 @@ inline UIImage *SDScaledImageForKey(NSString *key, UIImage *image) { | @@ -43,3 +43,5 @@ inline UIImage *SDScaledImageForKey(NSString *key, UIImage *image) { | ||
43 | return image; | 43 | return image; |
44 | } | 44 | } |
45 | } | 45 | } |
46 | + | ||
47 | +NSString *const SDWebImageErrorDomain = @"SDWebImageErrorDomain"; |
@@ -368,7 +368,7 @@ | @@ -368,7 +368,7 @@ | ||
368 | image = [UIImage decodedImageWithImage:image]; | 368 | image = [UIImage decodedImageWithImage:image]; |
369 | } | 369 | } |
370 | if (CGSizeEqualToSize(image.size, CGSizeZero)) { | 370 | if (CGSizeEqualToSize(image.size, CGSizeZero)) { |
371 | - completionBlock(nil, nil, [NSError errorWithDomain:@"SDWebImageErrorDomain" code:0 userInfo:@{NSLocalizedDescriptionKey : @"Downloaded image has 0 pixels"}], YES); | 371 | + completionBlock(nil, nil, [NSError errorWithDomain:SDWebImageErrorDomain code:0 userInfo:@{NSLocalizedDescriptionKey : @"Downloaded image has 0 pixels"}], YES); |
372 | } | 372 | } |
373 | else { | 373 | else { |
374 | completionBlock(image, self.imageData, nil, YES); | 374 | completionBlock(image, self.imageData, nil, YES); |
@@ -57,7 +57,7 @@ static char imageURLStorageKey; | @@ -57,7 +57,7 @@ static char imageURLStorageKey; | ||
57 | [self.imageURLStorage removeObjectForKey:@(state)]; | 57 | [self.imageURLStorage removeObjectForKey:@(state)]; |
58 | 58 | ||
59 | dispatch_main_async_safe(^{ | 59 | dispatch_main_async_safe(^{ |
60 | - NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; | 60 | + NSError *error = [NSError errorWithDomain:SDWebImageErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; |
61 | if (completedBlock) { | 61 | if (completedBlock) { |
62 | completedBlock(nil, error, SDImageCacheTypeNone, url); | 62 | completedBlock(nil, error, SDImageCacheTypeNone, url); |
63 | } | 63 | } |
@@ -128,7 +128,7 @@ static char imageURLStorageKey; | @@ -128,7 +128,7 @@ static char imageURLStorageKey; | ||
128 | [self sd_setBackgroundImageLoadOperation:operation forState:state]; | 128 | [self sd_setBackgroundImageLoadOperation:operation forState:state]; |
129 | } else { | 129 | } else { |
130 | dispatch_main_async_safe(^{ | 130 | dispatch_main_async_safe(^{ |
131 | - NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; | 131 | + NSError *error = [NSError errorWithDomain:SDWebImageErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; |
132 | if (completedBlock) { | 132 | if (completedBlock) { |
133 | completedBlock(nil, error, SDImageCacheTypeNone, url); | 133 | completedBlock(nil, error, SDImageCacheTypeNone, url); |
134 | } | 134 | } |
@@ -51,7 +51,7 @@ | @@ -51,7 +51,7 @@ | ||
51 | [self sd_setImageLoadOperation:operation forKey:UIImageViewHighlightedWebCacheOperationKey]; | 51 | [self sd_setImageLoadOperation:operation forKey:UIImageViewHighlightedWebCacheOperationKey]; |
52 | } else { | 52 | } else { |
53 | dispatch_main_async_safe(^{ | 53 | dispatch_main_async_safe(^{ |
54 | - NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; | 54 | + NSError *error = [NSError errorWithDomain:SDWebImageErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; |
55 | if (completedBlock) { | 55 | if (completedBlock) { |
56 | completedBlock(nil, error, SDImageCacheTypeNone, url); | 56 | completedBlock(nil, error, SDImageCacheTypeNone, url); |
57 | } | 57 | } |
@@ -71,7 +71,7 @@ static char imageURLKey; | @@ -71,7 +71,7 @@ static char imageURLKey; | ||
71 | [self sd_setImageLoadOperation:operation forKey:@"UIImageViewImageLoad"]; | 71 | [self sd_setImageLoadOperation:operation forKey:@"UIImageViewImageLoad"]; |
72 | } else { | 72 | } else { |
73 | dispatch_main_async_safe(^{ | 73 | dispatch_main_async_safe(^{ |
74 | - NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; | 74 | + NSError *error = [NSError errorWithDomain:SDWebImageErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; |
75 | if (completedBlock) { | 75 | if (completedBlock) { |
76 | completedBlock(nil, error, SDImageCacheTypeNone, url); | 76 | completedBlock(nil, error, SDImageCacheTypeNone, url); |
77 | } | 77 | } |
-
Please register or login to post a comment