From d020aea02fb808ee13e3dccbd910046f48bafe7b Mon Sep 17 00:00:00 2001 From: Matthew Knippen Date: Tue, 26 Nov 2013 16:54:59 -0600 Subject: [PATCH 1/2] added currentDownload Count, to allow someone to see how many operations are left. --- SDWebImage/SDWebImageDownloader.h | 6 ++++++ SDWebImage/SDWebImageDownloader.m | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/SDWebImage/SDWebImageDownloader.h b/SDWebImage/SDWebImageDownloader.h index b75b69a2..db57e9da 100644 --- a/SDWebImage/SDWebImageDownloader.h +++ b/SDWebImage/SDWebImageDownloader.h @@ -62,6 +62,12 @@ typedef void(^SDWebImageDownloaderCompletedBlock)(UIImage *image, NSData *data, @property (assign, nonatomic) NSInteger maxConcurrentDownloads; +/** + * Shows the current amount of downloads that still need to be downloaded + */ + +@property (readonly, nonatomic) NSUInteger currentDownloadCount; + /** * Changes download operations execution order. Default value is `SDWebImageDownloaderFIFOExecutionOrder`. */ diff --git a/SDWebImage/SDWebImageDownloader.m b/SDWebImage/SDWebImageDownloader.m index fb3bd13a..d8fb9cad 100644 --- a/SDWebImage/SDWebImageDownloader.m +++ b/SDWebImage/SDWebImageDownloader.m @@ -104,6 +104,10 @@ static NSString *const kCompletedCallbackKey = @"completed"; _downloadQueue.maxConcurrentOperationCount = maxConcurrentDownloads; } +- (NSUInteger)currentDownloadCount { + return _downloadQueue.operationCount; +} + - (NSInteger)maxConcurrentDownloads { return _downloadQueue.maxConcurrentOperationCount; From d0f8571dd216cc39b14612c12b88fbcaef5a2825 Mon Sep 17 00:00:00 2001 From: Matthew Knippen Date: Tue, 26 Nov 2013 21:29:10 -0600 Subject: [PATCH 2/2] matched coding conventions --- SDWebImage/SDWebImageDownloader.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SDWebImage/SDWebImageDownloader.m b/SDWebImage/SDWebImageDownloader.m index d8fb9cad..dcc303ef 100644 --- a/SDWebImage/SDWebImageDownloader.m +++ b/SDWebImage/SDWebImageDownloader.m @@ -104,7 +104,8 @@ static NSString *const kCompletedCallbackKey = @"completed"; _downloadQueue.maxConcurrentOperationCount = maxConcurrentDownloads; } -- (NSUInteger)currentDownloadCount { +- (NSUInteger)currentDownloadCount +{ return _downloadQueue.operationCount; }