【问题标题】:How to Add ASIHTTPRequest to a running ASINetworkQueue?如何将 ASIHTTPRequest 添加到正在运行的 ASINetworkQueue?
【发布时间】:2012-08-04 00:49:11
【问题描述】:

我一直在尝试使用 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;
}

【问题讨论】:

    标签: objective-c ios asihttprequest


    【解决方案1】:

    这样做:

    [networkQueue go];
    

    代替:

    if(!isDownloadOn)
        [networkQueue go];
    
    isDownloadOn = YES;
    

    您应该在添加下载请求时调用[networkQueue go]

    【讨论】:

    • 我之前也做过同样的事情...但是我的下载没有开始...allseeing-i.com/ASIHTTPRequest/How-to-use 搜索添加请求...以将其写入 networkQueue 的注释不需要一遍又一遍地调用
    猜你喜欢
    • 1970-01-01
    • 2012-02-27
    • 1970-01-01
    • 1970-01-01
    • 2020-02-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多