Skip to content

Commit d2da4d0

Browse files
author
Olivier Poitrey
committed
Merge pull request SDWebImage#929 from kirualex/patch-2
Handle empty urls NSArray
2 parents 2233b5e + 98082a6 commit d2da4d0

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

SDWebImage/SDWebImagePrefetcher.m

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,16 @@ - (void)prefetchURLs:(NSArray *)urls progress:(SDWebImagePrefetcherProgressBlock
120120
self.completionBlock = completionBlock;
121121
self.progressBlock = progressBlock;
122122

123-
// Starts prefetching from the very first image on the list with the max allowed concurrency
124-
NSUInteger listCount = self.prefetchURLs.count;
125-
for (NSUInteger i = 0; i < self.maxConcurrentDownloads && self.requestedCount < listCount; i++) {
126-
[self startPrefetchingAtIndex:i];
123+
if(urls.count == 0){
124+
if(completionBlock){
125+
completionBlock(0,0);
126+
}
127+
}else{
128+
// Starts prefetching from the very first image on the list with the max allowed concurrency
129+
NSUInteger listCount = self.prefetchURLs.count;
130+
for (NSUInteger i = 0; i < self.maxConcurrentDownloads && self.requestedCount < listCount; i++) {
131+
[self startPrefetchingAtIndex:i];
132+
}
127133
}
128134
}
129135

0 commit comments

Comments
 (0)