我正在使用 ASIHTTPRequest 进行多次下载。这里采用异步下载方式,可以进行多次下载。它工作正常。现在我想将这些下载文件保存到应用程序的本地文件夹(在设备中),并且还想检索它(想要获取每个文件的路径)。我怎样才能做到这一点?并且在这里执行多个下载,我如何区分下载中的每个文件?这是我使用的代码。
- (void)download{
UIImageView *image = (UIImageView *)[mainView viewWithTag:selectedTag];
for (UIProgressView *currentProgress in [image subviews]) {
if ([currentProgress isKindOfClass:[UIProgressView class]]) {
NSLog(@"Prog tag: %d",currentProgress.tag);
if(currentProgress)
{
currentProgress.progress = 0.0;
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:[urlArray objectAtIndex:selectedTag]]];
[request setDownloadProgressDelegate:currentProgress];
[request setShowAccurateProgress:YES];
[request setDownloadDestinationPath:[[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"mansory_porsche_carrera_3-1920x1200.jpg"]];
[request shouldContinueWhenAppEntersBackground];
[request allowResumeForFileDownloads];
[request startAsynchronous];
}
}
}
}