From 944fd77965cb0c174ead690adb50c3f09b9465dc Mon Sep 17 00:00:00 2001 From: KonstantinosK Date: Tue, 29 Sep 2015 10:27:09 +0300 Subject: [PATCH] Added a new constructor to SDWebImagePrefetcher that allows it to be instantiated with any image manager --- SDWebImage/SDWebImagePrefetcher.h | 5 +++++ SDWebImage/SDWebImagePrefetcher.m | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/SDWebImage/SDWebImagePrefetcher.h b/SDWebImage/SDWebImagePrefetcher.h index 7bb67ac3..6c31b15f 100644 --- a/SDWebImage/SDWebImagePrefetcher.h +++ b/SDWebImage/SDWebImagePrefetcher.h @@ -70,6 +70,11 @@ typedef void(^SDWebImagePrefetcherCompletionBlock)(NSUInteger noOfFinishedUrls, */ + (SDWebImagePrefetcher *)sharedImagePrefetcher; +/** + * Allows you to instantiate a prefetcher with any arbitrary image manager. + */ +- (id)initWithImageManager:(SDWebImageManager *)manager; + /** * Assign list of URLs to let SDWebImagePrefetcher to queue the prefetching, * currently one image is downloaded at a time, diff --git a/SDWebImage/SDWebImagePrefetcher.m b/SDWebImage/SDWebImagePrefetcher.m index 5fd483ba..76db95c0 100644 --- a/SDWebImage/SDWebImagePrefetcher.m +++ b/SDWebImage/SDWebImagePrefetcher.m @@ -37,8 +37,12 @@ } - (id)init { + return [self initWithImageManager:[SDWebImageManager new]]; +} + +- (id)initWithImageManager:(SDWebImageManager *)manager { if ((self = [super init])) { - _manager = [SDWebImageManager new]; + _manager = manager; _options = SDWebImageLowPriority; _prefetcherQueue = dispatch_get_main_queue(); self.maxConcurrentDownloads = 3;