I'm developing an iOS application and I'm using SDWebImage as an image downloader API.
I'm using a UICollectionView and I do it in the method
- (UICollectionViewCell *)collectionView:(SMToplinksCollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
Some images are downloaded, and some are not. The ones that does not downloaded shows the error message:
2014-06-15 12:11:50.203 c_shadow_ios_iphone[6867:60b] ===Error:Error Domain=NSURLErrorDomain Code=-1100 "The operation couldn’t be completed. (NSURLErrorDomain error -1100.)"
Error -1100: NSURLErrorFileDoesNotExist
Also, the UIImage seems to be nil.
I've checked the URL that SDWebImage tries to download and it gets me the image properly, so the Error does not seems reasonable
Here is the method code I use:
- (UICollectionViewCell *)collectionView:(SMToplinksCollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
SMToplinkCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:TopLinksCollectionViewID forIndexPath:indexPath];
NSArray *collectionViewArray = [self getToplinksArrayAccordingToTheIndex:collectionView.index];
// CONFIGURE THE CELL
SMTopLinksObject *dataObject = collectionViewArray[indexPath.item];
// 1. Set the toplink title
cell.title = dataObject.name;
// 2. Get the default image and blur it
cell.imageName = dataObject.localImageName;
// 3. Activate the preloader that shows the loading status
// 4. Load the image from the server
SDWebImageManager *manager = [SDWebImageManager sharedManager];
NSString *toplinksGetRequest = dataObject.prepareToplinksGetRequest;
NSURL *toplinksURL = [NSURL URLWithString:toplinksGetRequest];
NSLog(@"=== Trying to download image from URL:%@", toplinksGetRequest);
[manager downloadWithURL:toplinksURL
options:0
progress:^(NSInteger receivedSize, NSInteger expectedSize){
//progression tracking code
} completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished){
if(finished)
{
NSLog(@"===image finished loading, image:%@", image);
NSLog(@"===Error:%@", error);
}
if (image)
{ cell.shadowPageImageView.image = image; }
}];
NSLog(@"=========Cell:%@", cell);
return cell;
}
Output
image is NIL
Error: Error Domain=NSURLErrorDomain Code=-1100 "The operation couldn’t be completed. (NSURLErrorDomain error -1100.)"
What do I miss here?
[cell.diviceIV sd_setImageWithURL:[NSURL URLWithString:imgStringUrl] placeholderImage:nil options:SDWebImageRetryFailed completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
if (image){
// Set your image over here
}else{
//something went wrong
}
}];
The main point is options:SDWebImageRetryFailed option you need to give in your method. It works for me you can try it out.
I had the same issue. I got "Error Domain=SDWebImageErrorDomain Code=-1 "Trying to load a nil url", but the image is present in that particular url. I found that,the error occurs for low resolution images. For better quality images , the loading happens well. Check the same code for better resolution images.
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