i have to download large number of web images in my app. now i am trying to download images in my initial class using Grand Central Dispatch.
code:
- (void)viewDidLoad
{
[super viewDidLoad];
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0ul);
dispatch_async(queue, ^{
// Perform non main thread operation
for (NSString *imageURL in tempoaryArr1) {
NSURL *url = [NSURL URLWithString:imageURL];
SDWebImageManager *manager = [SDWebImageManager sharedManager];
[manager downloadWithURL:url
delegate:self
options:0
success:^(UIImage *image, BOOL cached)
{
}
failure:nil];
}
dispatch_sync(dispatch_get_main_queue(), ^{
// perform main thread operation
});
});
}
But the above code only download 30 to 40 images at the first launch of app after that it stop downloading images in cache until i stop the app and run it again then the second time it download the some more images in cache and after that stop downloading so on.
So my question is why it stop after downloading some images,i want that it keeps downloading images in cache until it download all the images.