I am downloading a bunch of images via ASINetworkQueue
. I have no problems in the simulator, but on the iPad some of the images (each time they are different) are not downloaded. How can I fix this?
Here is the code:
Queue Creation:
if (addedPaintings > 0) {
[currentPaintingsArray addObjectsFromArray:objectsToAdd];
[unseenPaintings addObjectsFromArray:objectsToAdd];
[self downloadImages];
}
// update plist file if data was altered.
if (addedPaintings > 0 || removedPaintings > 0)
[currentPaintingsArray writeToFile:dataFilePath atomically:YES];
else
[self completeSync:request.responseStatusCode];
}
Image Download method:
- (void) downloadImages {
[networkQueue reset];
[networkQueue setDelegate:self];
[networkQueue setShowAccurateProgress:YES];
[networkQueue setDownloadProgressDelegate:self.progressView.customView];
[networkQueue setQueueDidFinishSelector:@selector(imageQueueDownloadComplete:)];
for (NSDictionary *dict in [Globals sharedGlobals].unseenPaintings) {
NSString *link = [dict objectForKey:@"link"];
NSString *smallLink = [dict objectForKey:@"smallLink"];
if ([link length] != 0) {
NSURL *url = [NSURL URLWithString:[[URL stringByAppendingString:GALLERY] stringByAppendingString: link]];
ASIHTTPRequest *downloadRequest = [[ASIHTTPRequest alloc] initWithURL:url];
[downloadRequest setDownloadDestinationPath:[documentsDirectory stringByAppendingPathComponent:link]];
[downloadRequest setDidFailSelector:@selector(imageDownloadFailed:)];
[downloadRequest setDidFinishSelector:@selector(imageDownloadComplete:)];
[downloadRequest setUserInfo:dict];
[downloadRequest setDelegate:self];
[networkQueue addOperation:downloadRequest];
[downloadRequest release];
NSURL *urlCarousel = [NSURL URLWithString:[[URL stringByAppendingString:WS_IMAGES] stringByAppendingString: smallLink]];
downloadRequest = [[ASIHTTPRequest alloc] initWithURL:urlCarousel];
[downloadRequest setDownloadDestinationPath:[documentsDirectory stringByAppendingPathComponent:smallLink]];
[downloadRequest setDidFailSelector:@selector(imageDownloadFailed:)];
[downloadRequest setUserInfo:dict];
[downloadRequest setDelegate:self];
[networkQueue addOperation:downloadRequest];
[downloadRequest release];
}
}
[networkQueue go];
}