diff --git a/SDWebImageManager.m b/SDWebImageManager.m index fd20f154..8f9c9ad9 100644 --- a/SDWebImageManager.m +++ b/SDWebImageManager.m @@ -9,6 +9,7 @@ #import "SDWebImageManager.h" #import "SDImageCache.h" #import "SDWebImageDownloader.h" +#import static SDWebImageManager *instance; @@ -165,6 +166,10 @@ static SDWebImageManager *instance; { [delegate performSelector:@selector(webImageManager:didFinishWithImage:) withObject:self withObject:image]; } + if ([delegate respondsToSelector:@selector(webImageManager:didFinishWithImage:forURL:)]) + { + objc_msgSend(delegate, @selector(webImageManager:didFinishWithImage:forURL:), self, image, url); + } [cacheDelegates removeObjectAtIndex:idx]; [cacheURLs removeObjectAtIndex:idx]; @@ -229,6 +234,10 @@ static SDWebImageManager *instance; { [delegate performSelector:@selector(webImageManager:didFinishWithImage:) withObject:self withObject:image]; } + if ([delegate respondsToSelector:@selector(webImageManager:didFinishWithImage:forURL:)]) + { + objc_msgSend(delegate, @selector(webImageManager:didFinishWithImage:forURL:), self, image, downloader.url); + } } else { @@ -236,6 +245,10 @@ static SDWebImageManager *instance; { [delegate performSelector:@selector(webImageManager:didFailWithError:) withObject:self withObject:nil]; } + if ([delegate respondsToSelector:@selector(webImageManager:didFailWithError:forURL:)]) + { + objc_msgSend(delegate, @selector(webImageManager:didFailWithError:forURL:), self, nil, downloader.url); + } } [downloaders removeObjectAtIndex:uidx]; @@ -283,6 +296,10 @@ static SDWebImageManager *instance; { [delegate performSelector:@selector(webImageManager:didFailWithError:) withObject:self withObject:error]; } + if ([delegate respondsToSelector:@selector(webImageManager:didFailWithError:forURL:)]) + { + objc_msgSend(delegate, @selector(webImageManager:didFailWithError:forURL:), self, error, downloader.url); + } [downloaders removeObjectAtIndex:uidx]; [downloadDelegates removeObjectAtIndex:uidx]; diff --git a/SDWebImageManagerDelegate.h b/SDWebImageManagerDelegate.h index cd27d8e6..8592076b 100644 --- a/SDWebImageManagerDelegate.h +++ b/SDWebImageManagerDelegate.h @@ -14,6 +14,8 @@ @optional - (void)webImageManager:(SDWebImageManager *)imageManager didFinishWithImage:(UIImage *)image; +- (void)webImageManager:(SDWebImageManager *)imageManager didFinishWithImage:(UIImage *)image forURL:(NSURL *)url; - (void)webImageManager:(SDWebImageManager *)imageManager didFailWithError:(NSError *)error; +- (void)webImageManager:(SDWebImageManager *)imageManager didFailWithError:(NSError *)error forURL:(NSURL *)url; @end