在NSURLConnection中恢复下载功能 [英] Resume download functionality in NSURLConnection

查看:107
本文介绍了在NSURLConnection中恢复下载功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从NSURLConnection类的服务器下载一些非常大的数据。

I am downloading some very large data from a server with the NSURLConnection class.

如何实现暂停功能以便我可以继续下载?

How can I implement a pause facility so that I can resume downloading?

推荐答案

你不能暂停,但你可以取消连接,然后创建一个新的连接,以恢复旧的离开了。但是,您要连接的服务器必须支持Range标头。将其设置为bytes = size_already_downloaded-,它应该在你取消它的地方找到。

You can't pause, per-se, but you can cancel a connection, and then create a new one to resume where the old left off. However, the server you're connecting to must support the Range header. Set this to "bytes=size_already_downloaded-", and it should pick up right where you cancelled it.

这篇关于在NSURLConnection中恢复下载功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆