Search code examples
iossdwebimage

want to know if the image is not available at url using SDWebImage


in my application i am downloading an image from url from webservice using SDWebImage Library. I have nothing problem with this code

[imgQuestionContainer sd_setImageWithURL:[NSURL URLWithString:@"url"] placeholderImage:@"abc.png" options:SDWebImageProgressiveDownload];

with above code i have successfully load the image in imageview...

But my problem is that if i have url for the image but image is not available at that particular path of url. So, how to know that image is not available so i can load next data.

Thanks.


Solution

  • This is what exactly i wanted.

    [imgQuestionContainer sd_setImageWithURL:[NSURL URLWithString:[[arrOfLoadedPuzzel objectAtIndex:0] objectForKey:@"puzzle_question"]]
                      placeholderImage:nil
                             completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL)
                            {
                                if(error)
                                {
                                     // image is not available
                                }
                                else
                                {
                                     // image is available
                                }
                           }];