Add cancelAll method (fix #168)

This commit is contained in:
Olivier Poitrey 2012-11-04 01:51:19 +01:00
parent 55fd4a1d77
commit 8963f996e9
2 changed files with 20 additions and 0 deletions

View File

@ -153,4 +153,9 @@ typedef NSString *(^CacheKeyFilter)(NSURL *url);
*/
- (void)cancelForDelegate:(id<SDWebImageManagerDelegate>)delegate;
/**
* Cancel all current opreations
*/
- (void)cancelAll;
@end

View File

@ -209,6 +209,21 @@ static SDWebImageManager *instance;
}
}
- (void)cancelAll
{
for (SDWebImageDownloader *downloader in downloaders)
{
[downloader cancel];
}
[cacheDelegates removeAllObjects];
[cacheURLs removeAllObjects];
[downloadInfo removeAllObjects];
[downloadDelegates removeAllObjects];
[downloaders removeAllObjects];
[downloaderForURL removeAllObjects];
}
#pragma mark SDImageCacheDelegate
- (NSUInteger)indexOfDelegate:(id<SDWebImageManagerDelegate>)delegate waitingForURL:(NSURL *)url