ASIHttpRequest 恢复下载

发布于 2024-11-16 09:18:53 字数 708 浏览 4 评论 0原文

我有一个与这篇文章类似的问题 ASIHTTP 异步 pdf 下载

我要恢复下载使用 setTemporaryFileDownloadPath: 但奇怪的是,当我调用 setDelegate 到 self 并异步启动连接时,缓存不会将其保存到temporFileDownloadPath 但我注释了设置的委托,缓存将保存到该路径。

    _conn = [[ASIHTTPRequest alloc] initWithURL:_currentURL];
    [_conn setDownloadDestinationPath:_currentFileNameWithPath]; 
    [_conn setTemporaryFileDownloadPath:tempPdfLocation];     
    [_conn setAllowResumeForFileDownloads:YES];
    //[_conn setDelegate:self];
    [_conn startAsynchronous];

我发现每当 - (void)request:(ASIHTTPRequest *)request didReceiveData:(NSData *)data: 被调用时,缓存都不会保存。有什么想法吗?

I've got question that similiar to this post ASIHTTP asynchrounous pdf download

I am going to resume download using setTemporaryFileDownloadPath: but the weird thing is when I called setDelegate to self and start the connection asynchronously, the cache won't save it to temporaryFileDownloadPath but instead I remark the set delegate, the cache will save to the path.

    _conn = [[ASIHTTPRequest alloc] initWithURL:_currentURL];
    [_conn setDownloadDestinationPath:_currentFileNameWithPath]; 
    [_conn setTemporaryFileDownloadPath:tempPdfLocation];     
    [_conn setAllowResumeForFileDownloads:YES];
    //[_conn setDelegate:self];
    [_conn startAsynchronous];

I've found that whenever - (void)request:(ASIHTTPRequest *)request didReceiveData:(NSData *)data: was called the cache won't saved. Any Idea?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

飞烟轻若梦 2024-11-23 09:18:53

我用的是同样的东西。唯一的区别是我必须设置以下选择器:

[_conn setDidFailSelector:@selector(downloadDidFail:)];
[_conn setDidFinishSelector:@selector(downloadDidFinish:)];
[_conn setDidStartSelector:@selector(downloadDidStart:)];

并且不实现 ASIHTTPRequestDelegate 协议中指定为可选的任何其他委托方法。现在下载工作正常,并且会在需要时调用设置选择器。

I used the same thing. Only difference is that I had to set the following selectors:

[_conn setDidFailSelector:@selector(downloadDidFail:)];
[_conn setDidFinishSelector:@selector(downloadDidFinish:)];
[_conn setDidStartSelector:@selector(downloadDidStart:)];

And not implement any of the other delegate methods specified as optional in the ASIHTTPRequestDelegate protocol. Now the download works perfectly and will call the set selectors when needed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文