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?