Prashant Prashant - 9 months ago 76
Objective-C Question

Download Images One By One with url using SDWebimage

I need to Download images from

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
for Download Images.
Please Help me.



You can try something like this

-(void)downloadImage {
     NSURL *url = [NSURL URLWithString:[self.urlArray firstObject]];
     SDWebImageManager *manager = [SDWebImageManager sharedManager];
     [manager downloadImageWithURL:imageURL
                 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

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.