In ios 6, I have an image downloader method that calls sendAsynchronousRequest. When number of images are too many completion blocks are never called and there are over 60 worker threads that are never destroyed(so the image downloading is never completed). In ios 7 it seems to be working fine. How do you make this work? code is as below
for(NSDictionary * imageDict in thumbnailJSONArray){
NSString * thumbNailString = [imageDict objectForKey:JSON_URL];
//other codes..
[self downLoadThumbNails:numbertoAdd urlRequest:thumbNailString];
}
-(void)downLoadThumbNails:(NSUInteger) numberToAdd urlRequest:(NSString*)urlString {
if(self.imageQueue == nil){
self.imageQueue = [[NSOperationQueue alloc] init];
}
[NSURLConnection sendAsynchronousRequest:urlRequest queue:self.imageQueue completionHandler:^(NSURLResponse *response, NSData* data, NSError *connectionError) {
//image setting codes
}];
}
--EDIT-- To be more clear, image setting codes are never called, so the downloaded images are never set.