Added a new constructor to SDWebImagePrefetcher
that allows it to be instantiated with any image manager
Showing
2 changed files
with
10 additions
and
1 deletions
@@ -71,6 +71,11 @@ typedef void(^SDWebImagePrefetcherCompletionBlock)(NSUInteger noOfFinishedUrls, | @@ -71,6 +71,11 @@ typedef void(^SDWebImagePrefetcherCompletionBlock)(NSUInteger noOfFinishedUrls, | ||
71 | + (SDWebImagePrefetcher *)sharedImagePrefetcher; | 71 | + (SDWebImagePrefetcher *)sharedImagePrefetcher; |
72 | 72 | ||
73 | /** | 73 | /** |
74 | + * Allows you to instantiate a prefetcher with any arbitrary image manager. | ||
75 | + */ | ||
76 | +- (id)initWithImageManager:(SDWebImageManager *)manager; | ||
77 | + | ||
78 | +/** | ||
74 | * Assign list of URLs to let SDWebImagePrefetcher to queue the prefetching, | 79 | * Assign list of URLs to let SDWebImagePrefetcher to queue the prefetching, |
75 | * currently one image is downloaded at a time, | 80 | * currently one image is downloaded at a time, |
76 | * and skips images for failed downloads and proceed to the next image in the list | 81 | * and skips images for failed downloads and proceed to the next image in the list |
@@ -37,8 +37,12 @@ | @@ -37,8 +37,12 @@ | ||
37 | } | 37 | } |
38 | 38 | ||
39 | - (id)init { | 39 | - (id)init { |
40 | + return [self initWithImageManager:[SDWebImageManager new]]; | ||
41 | +} | ||
42 | + | ||
43 | +- (id)initWithImageManager:(SDWebImageManager *)manager { | ||
40 | if ((self = [super init])) { | 44 | if ((self = [super init])) { |
41 | - _manager = [SDWebImageManager new]; | 45 | + _manager = manager; |
42 | _options = SDWebImageLowPriority; | 46 | _options = SDWebImageLowPriority; |
43 | _prefetcherQueue = dispatch_get_main_queue(); | 47 | _prefetcherQueue = dispatch_get_main_queue(); |
44 | self.maxConcurrentDownloads = 3; | 48 | self.maxConcurrentDownloads = 3; |
-
Please register or login to post a comment