iPhone SDK:暂停NSURLConnection? [英] iphone sdk: pausing NSURLConnection?
问题描述
在我的应用程序中,我使用户能够从服务器下载文件.为此,我使用NSURLConnection.我想让用户可以通过点击按钮来暂停和继续下载.除了调用cancel方法然后创建一个新的NSURLConnection之外,我找不到任何其他方法.那么有没有一种优雅的方式来暂停NSURLConnection?
In my app I give the user the ability to download files from a server. For that I use NSURLConnection. I would like to give the user the ability to pause and resume the download by tapping a button. I couldn't find any way to do this besides calling the cancel method and then creating a new NSURLConnection. So is there an elegant way to pause NSURLConnection?
谢谢
推荐答案
这是我所知道的唯一方法.如果您的服务器支持"Range:"标头,则可以创建一个新连接,并从另一个断开的位置开始连接.
That's the only method I'm aware of. If your server supports the "Range:" header, you can then create a new connection and have it pick up where the other one left off.
这篇关于iPhone SDK:暂停NSURLConnection?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!