SDWebImage - SDWebImagePrefetcher not using transformDownloadedImage

1.4k views Asked by At

I am currently successfully using 'SDWebImageManager downloadImageWithURL' for downloading single images , followed by the delegate method 'transformDownloadedImage' automatically called upon completion to resize the images before caching them.

I would like, however, in the background to prefetch a bunch of images (~25) not yet displayed using the prefetcher code below in a similar way. However the problem is that the 'transformDownloadedImage' delegate is not called upon completion (of 1 or all the images) - images are cached as is.

    SDWebImagePrefetcher *prefetcher = [SDWebImagePrefetcher sharedImagePrefetcher];
    [prefetcher prefetchURLs:array progress:nil completed:^(NSUInteger completedNo, NSUInteger skippedNo) {
    }];

Am I missing something? or is there some other efficient way to do this by pulling out the cached images upon completion, resizing, and reinserting? I am using "UIImage+Resize" to resize and manipulate, and obviously this needs to happen in background without blocking the UI.

Any and all advice about how to go about this efficiently will be greatly appreciated!

1

There are 1 answers

2
Artal On BEST ANSWER

If you look at the implementation of SDWebImagePrefetcher you'll notice that it's using SDWebImageManager to perform the downloads, and it's available as a property. So you should be able to do something like this:

prefetcher.manager.delegate = self;

Now you can implement the downloadImageWithURL delegate method as you did before. I didn't try it but it should work.