我一直在尝试使用ASIHTTP库发出多个下载请求。我能够开始下载第一个请求...但是当我向队列添加另一个ASIHTTPRequest时,它没有下载..你能不能建议下一个下载开始...
-(void)createNewDownloadRequestWithURL:(NSString *)videoURL andProgressIndicator: (UIProgressView *)progressView andDelegate:(id)delegate
{
ASIHTTPRequest *request;
request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:videoURL]];
NSString * destFilePath = [[[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"Videos"] stringByAppendingPathComponent:[videoURL lastPathComponent]];
[request setDownloadDestinationPath:destFilePath];
[request setDownloadProgressDelegate:progressView];
[request setAllowResumeForFileDownloads:YES];
[request setTemporaryFileDownloadPath:[NSString stringWithFormat:@"%@.download",destFilePath]];
[request setUserInfo:[NSDictionary dictionaryWithObjectsAndKeys:[videoURL lastPathComponent],@"name",delegate,@"delegate",nil]];
request.delegate = self;
request.tag = VIDEO_DOWNLOAD_REQUEST;
[networkQueue addOperation:request];
if(!isDownloadOn)
[networkQueue go];
isDownloadOn = YES;
}
答案 0 :(得分:0)
这样做:
[networkQueue go];
而不是:
if(!isDownloadOn)
[networkQueue go];
isDownloadOn = YES;
添加下载请求时应调用[networkQueue go]
。