Add some callback methods to SDWebImageManager protocol with requested URL appended (fix #67)
This commit is contained in:
parent
3074f55de2
commit
30b9534294
|
@ -9,6 +9,7 @@
|
|||
#import "SDWebImageManager.h"
|
||||
#import "SDImageCache.h"
|
||||
#import "SDWebImageDownloader.h"
|
||||
#import <objc/message.h>
|
||||
|
||||
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];
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue