I need to Download images from Array
of Url's, one by one and Display all at a Time.
Ex. I have an array of 10 URL's and I need to Download image One By One only, and display at a time.
I am Using SDWebImage
for Download Images.
Please Help me.
Thanks.
You can try something like this
-(void)downloadImage {
if self.urlArray.count > 0) {
NSURL *url = [NSURL URLWithString:[self.urlArray firstObject]];
SDWebImageManager *manager = [SDWebImageManager sharedManager];
[manager downloadImageWithURL:imageURL
options:0
progress:^(NSInteger receivedSize, NSInteger expectedSize) {
// progression tracking code
}
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
if (image) {
[self.imageArray addObject:image];
[self.urlArray removeObjectAtIndex:0];
[self downloadImage];
}
else {
[self downloadImage]; //try download once again
}
}];
}
else {
NSLog(@"All Images are downloaded do what u want")
}
}
Note:- Here urlArray
is array of string url and imageArray
array contain all the image that you have download.
call this method after you have got all the string url in urlArray
.
Hope this will help you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With