Start a new topic

Downloading multiple images

My app is to list out all the product images. Using custom endpoint i have queried from different collections and using the below UIImageView Category code i am downloading all the images,



```#import "UIImageView+SetFile.h"

@implementation UIImageView (SetFile)

@dynamic file;

-(void)setFile:(id)file{

[KCSFileStore downloadFile:[file valueForKey:@"_id"] options:@{KCSFileOnlyIfNewer:@(YES)} completionBlock:^(NSArray *downloadedResources, NSError *error) {

if (error == nil) {

KCSFile* filetmp = downloadedResources[0];

NSURL* fileURL = filetmp.localURL;

UIImage* image = [UIImage imageWithContentsOfFile:[fileURL path]]; //note this blocks for awhile

dispatch_queue_t mainThreadQueue = dispatch_get_main_queue();

dispatch_async(mainThreadQueue, ^{

self.image = image;

});

} else {

NSLog(@"%@",error);

dispatch_queue_t mainThreadQueue = dispatch_get_main_queue();

dispatch_async(mainThreadQueue, ^{

self.image = [UIImage imageNamed:@"noImage"];

});

}

} progressBlock:^(NSArray *objects, double percentComplete){

// handler(percentComplete);

NSLog(@"%@",objects);

NSLog(@"%f",percentComplete);

}];



}

@end```



While downloading the image on the tableview when i scroll then download get stopped and throws me the below error,

Error Domain=KCSResourceErrorDomain Code=60011 "Download already in progress." UserInfo=0x101b9c20 {NSLocalizedDescription=Download already in progress.}



Appreciate if anyone ready to help me to get rid of this issue. Thanks



1 Comment

What version of the library are you using?
Login or Signup to post a comment