我正在做一个项目,我需要为服务器下载 3 个不同的 .plist 文件,但我只能下载其中一个。谁知道怎么把这三个都下载下来?我正在使用 ASIHTTPRequest。我的代码:
- (void)downloadPlist {
NSLog(@"Download in progress...");
progressView.alpha = 1.0;
// Here we're downloading the .plist file from a server to the app's Documents Directory.
// Create file manager
fileManager = [NSFileManager defaultManager];
// Point to Document directory
documentsDirectory = [NSHomeDirectory()
stringByAppendingPathComponent:@"Documents"];
documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
filePath = [documentsDirectory stringByAppendingPathComponent:@"example1.plist"];
filePath = [documentsDirectory stringByAppendingPathComponent:@"example2.plist"];
filePath = [documentsDirectory stringByAppendingPathComponent:@"example3.plist"];
// files from server.
NSURL *url = [NSURL URLWithString:@"http://myWeb.com/example1.plist"];
NSURL *url1 = [NSURL URLWithString:@"http://myWeb.com/example2.plist"];
NSURL *url2 = [NSURL URLWithString:@"http://myWeb.com/example3.plist"];
request = [ASIHTTPRequest requestWithURL:url];
request = [ASIHTTPRequest requestWithURL:url1];
request = [ASIHTTPRequest requestWithURL:url2];
[request setShowAccurateProgress:YES];
[request setDownloadDestinationPath:filePath];
[request setDownloadProgressDelegate:progressView];
[request setDelegate:self];
[request startAsynchronous];
}
我想我在正确的轨道上,但不确定......干杯!