如果应用程序在前台时使用 NSURLConnection 开始下载,但随后在数据下载完成之前应用程序移动到后台,那么应用程序应该如何使用 beginbackgroundtaskwithexpirationhandler:对于这个已经存在的连接?
有大量引用资料显示如何使用 NSURLConnection initWithRequest: 在应用程序进入后台后开始下载,但没有显示如何处理 NSURLConnection initWithRequest: 已在应用程序中调用的情况处于前台但尚未完成时应用程序移至后台以及如何继续。
TIA
最佳答案
对于您希望在后台继续执行的任务,您需要将其作为后台任务启动,即使该任务在前台开始也是如此。查看此 Apple 文档中的“超越基础知识”部分:https://developer.apple.com/library/ios/ipad/#technotes/tn2277/_index.html
关于ios - 应该如何开始后台任务和过期处理程序 : be dealt with for an NSUrlConnection that is already in progress?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9136890/