Authored by Olivier Poitrey

Merge pull request #929 from kirualex/patch-2

Handle empty urls NSArray
@@ -120,11 +120,17 @@ @@ -120,11 +120,17 @@
120 self.completionBlock = completionBlock; 120 self.completionBlock = completionBlock;
121 self.progressBlock = progressBlock; 121 self.progressBlock = progressBlock;
122 122
  123 + if(urls.count == 0){
  124 + if(completionBlock){
  125 + completionBlock(0,0);
  126 + }
  127 + }else{
123 // Starts prefetching from the very first image on the list with the max allowed concurrency 128 // Starts prefetching from the very first image on the list with the max allowed concurrency
124 NSUInteger listCount = self.prefetchURLs.count; 129 NSUInteger listCount = self.prefetchURLs.count;
125 for (NSUInteger i = 0; i < self.maxConcurrentDownloads && self.requestedCount < listCount; i++) { 130 for (NSUInteger i = 0; i < self.maxConcurrentDownloads && self.requestedCount < listCount; i++) {
126 [self startPrefetchingAtIndex:i]; 131 [self startPrefetchingAtIndex:i];
127 } 132 }
  133 + }
128 } 134 }
129 135
130 - (void)cancelPrefetching { 136 - (void)cancelPrefetching {