Skip to content

Commit

Permalink
Added a new constructor to SDWebImagePrefetcher
Browse files Browse the repository at this point in the history
that allows it to be instantiated with any image manager
  • Loading branch information
KonstantinosK committed Sep 29, 2015
1 parent 60cab8b commit 944fd77
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions SDWebImage/SDWebImagePrefetcher.h
Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion SDWebImage/SDWebImagePrefetcher.m
Expand Up @@ -37,8 +37,12 @@ + (SDWebImagePrefetcher *)sharedImagePrefetcher {
}

- (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;
Expand Down

0 comments on commit 944fd77

Please sign in to comment.