Fixed bug where NSInvalidArgumentException was thrown if an image with a nil URL was downloaded.

This commit is contained in:
Reid Main 2013-01-16 14:53:38 -05:00
parent bc29d0a7ae
commit b59b42e6b5
1 changed files with 11 additions and 0 deletions

View File

@ -144,6 +144,17 @@ static NSString *const kCompletedCallbackKey = @"completed";
- (void)addProgressCallback:(void (^)(NSUInteger, long long))progressBlock andCompletedBlock:(void (^)(UIImage *, NSData *data, NSError *, BOOL))completedBlock forURL:(NSURL *)url createCallback:(void (^)())createCallback
{
// The URL will be used as the key to the callbacks dictionary so it cannot be nil. If it is nil immediately call the completed block with no image or data and an error.
if(url == nil)
{
if (completedBlock != nil)
{
NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:0 userInfo:@{NSLocalizedDescriptionKey: @"Could not load an image because URL was nil."}];
completedBlock(nil, nil, error, NO);
}
return;
}
dispatch_barrier_sync(self.barrierQueue, ^
{
BOOL first = NO;