Handle empty urls NSArray

In some cases the user may end up with an empty urls NSArray, in which case the completion block is never called.
This commit handle such case to call immediately the completion block (if any)
This commit is contained in:
Alexis Creuzot 2014-10-14 11:16:58 +02:00
parent 2233b5e77d
commit 98082a6791
1 changed files with 10 additions and 4 deletions

View File

@ -120,10 +120,16 @@
self.completionBlock = completionBlock;
self.progressBlock = progressBlock;
// Starts prefetching from the very first image on the list with the max allowed concurrency
NSUInteger listCount = self.prefetchURLs.count;
for (NSUInteger i = 0; i < self.maxConcurrentDownloads && self.requestedCount < listCount; i++) {
[self startPrefetchingAtIndex:i];
if(urls.count == 0){
if(completionBlock){
completionBlock(0,0);
}
}else{
// Starts prefetching from the very first image on the list with the max allowed concurrency
NSUInteger listCount = self.prefetchURLs.count;
for (NSUInteger i = 0; i < self.maxConcurrentDownloads && self.requestedCount < listCount; i++) {
[self startPrefetchingAtIndex:i];
}
}
}