Authored by robertmryan

Adjusted completion logic in prefetcher, as the old implementation would finish …

…prematurely if any requests were skipped.

Also adjusted documentation in headers to make it clear that the `finishedCount` includes both successful and unsuccessful requests.
@@ -20,15 +20,15 @@ @@ -20,15 +20,15 @@
20 * 20 *
21 * @param imagePrefetcher The current image prefetcher 21 * @param imagePrefetcher The current image prefetcher
22 * @param imageURL The image url that was prefetched 22 * @param imageURL The image url that was prefetched
23 - * @param finishedCount The total number of images that were prefetched  
24 - * @param totalCount The total number of images that need to be prefetched 23 + * @param finishedCount The total number of images that were prefetched (successful or not)
  24 + * @param totalCount The total number of images that were to be prefetched
25 */ 25 */
26 - (void)imagePrefetcher:(SDWebImagePrefetcher *)imagePrefetcher didPrefetchURL:(NSURL *)imageURL finishedCount:(NSUInteger)finishedCount totalCount:(NSUInteger)totalCount; 26 - (void)imagePrefetcher:(SDWebImagePrefetcher *)imagePrefetcher didPrefetchURL:(NSURL *)imageURL finishedCount:(NSUInteger)finishedCount totalCount:(NSUInteger)totalCount;
27 27
28 /** 28 /**
29 * Called when all images are prefetched. 29 * Called when all images are prefetched.
30 * @param imagePrefetcher The current image prefetcher 30 * @param imagePrefetcher The current image prefetcher
31 - * @param totalCount The total number of images that need to be prefetched 31 + * @param totalCount The total number of images that were prefetched (whether successful or not)
32 * @param skippedCount The total number of images that were skipped 32 * @param skippedCount The total number of images that were skipped
33 */ 33 */
34 - (void)imagePrefetcher:(SDWebImagePrefetcher *)imagePrefetcher didFinishWithTotalCount:(NSUInteger)totalCount skippedCount:(NSUInteger)skippedCount; 34 - (void)imagePrefetcher:(SDWebImagePrefetcher *)imagePrefetcher didFinishWithTotalCount:(NSUInteger)totalCount skippedCount:(NSUInteger)skippedCount;
@@ -73,7 +73,7 @@ @@ -73,7 +73,7 @@
73 * and skips images for failed downloads and proceed to the next image in the list 73 * and skips images for failed downloads and proceed to the next image in the list
74 * 74 *
75 * @param urls list of URLs to prefetch 75 * @param urls list of URLs to prefetch
76 - * @param progressBlock block to be called when progress updates 76 + * @param progressBlock block to be called when progress updates; first parameter is the number of completed (successful or not) requests, second parameter is the total number of images originally requested to be prefetched
77 * @param completionBlock block to be called when prefetching is completed 77 * @param completionBlock block to be called when prefetching is completed
78 */ 78 */
79 - (void)prefetchURLs:(NSArray *)urls progress:(void (^)(NSUInteger, NSUInteger))progressBlock completed:(void (^)(NSUInteger, NSUInteger))completionBlock; 79 - (void)prefetchURLs:(NSArray *)urls progress:(void (^)(NSUInteger, NSUInteger))progressBlock completed:(void (^)(NSUInteger, NSUInteger))completionBlock;
@@ -88,7 +88,7 @@ @@ -88,7 +88,7 @@
88 [self startPrefetchingAtIndex:self.requestedCount]; 88 [self startPrefetchingAtIndex:self.requestedCount];
89 }); 89 });
90 } 90 }
91 - else if (self.finishedCount + self.skippedCount == self.requestedCount) { 91 + else if (self.finishedCount == self.requestedCount) {
92 [self reportStatus]; 92 [self reportStatus];
93 if (self.completionBlock) { 93 if (self.completionBlock) {
94 self.completionBlock(self.finishedCount, self.skippedCount); 94 self.completionBlock(self.finishedCount, self.skippedCount);