简体   繁体   English

iPhone锁定和解锁时,ASIHTTPREQUEST给出错误(1)

[英]ASIHTTPREQUEST gives error (1) when iPhone is locked and unlocked

I am using ASIHTTPREQUEST to do asynchronous network connections in my app. 我正在使用ASIHTTPREQUEST在我的应用程序中进行异步网络连接。 For the most part it works great. 在大多数情况下,它都很棒。 However, if I am running a connection, and lock the phone (but leave the app open), and the unlock it, I get the following error on my connections: 但是,如果我正在运行连接,然后锁定手机(但保持应用处于打开状态)并解锁,则在连接时会出现以下错误:

ErrorDomain=ASIHTTPREQUESTErrorDomain Code=1 "The operation could not be completed." “ ErrorDomain = ASIHTTPREQUESTErrorDomain代码= 1”该操作无法完成。 (ASIHTTPREQUESTErrorDomain error 1.) (ASIHTTPREQUESTErrorDomain错误1。)

How can I stop this from happening, or even make the HTTP requests continue to work even if the phone has been locked or the screen shuts off? 我如何才能阻止这种情况的发生,甚至即使手机已锁定或屏幕关闭,也无法使HTTP请求继续工作?

Start a background task with UIApplication 's beginBackgroundTaskWithExpirationHandler: method before initiating the request. 在启动请求之前,使用UIApplicationbeginBackgroundTaskWithExpirationHandler:方法启动后台任务。 End the background task when the request returns with success or failure and you have processed the data from the request. 当请求成功或失败返回并且您已经处理了请求中的数据时,结束后台任务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM