iPhone Web服务请求超时 [英] iPhone Web service Request Timeout

查看:76
本文介绍了iPhone Web服务请求超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于无线信号较弱,我的iPhone应用程序出现了问题.我的应用程序使用Web服务从我们的服务器中检索数据,但是当Wifi信号较弱时,响应再也不会回来,并且用户会卡在正在加载..."覆盖屏幕上.最后,应用程序最终崩溃了.我如何优雅地处理这种情况.有没有办法为我的网络服务调用或类似的设置超时?

I am having problems in my iphone application due to weak wifi signals. My application uses webservice to retireve data from our server but when Wifi signals are weak the response never comes back and user gets stuck on "Loading..." overlay screen. Finally the application crashes at the end. How can i handle this situation gracefully. Is there a way to set TimeOut for my webservice calls or something like this?

谢谢,阿西夫.

推荐答案

您可以设置NSURLConnection超时和委托来响应 connection:didFailWithError:选择器.参见此S.O.主题.

You can set the NSURLConnection timeout and a delegate to respond to connection:didFailWithError: selector. See this S.O. topic.

如果您的代表从不被呼叫,这就是已知问题.唯一的解决方法似乎是将您自己的NSTimer设置为在一段时间后触发并取消请求.绝对是很尴尬,但不应该那么复杂.

if your delegate is never being called, this is a somehow known issue. The only workaround seems to be setting your own NSTimer to fire after some time and cancel the request. It is definitely awkard, but it should not be that complex.

如果您对超时问题背后的原因感到好奇,那似乎与iPhone中3G子系统启动缓慢有关.

If you are curious about the reason behind the issue with timeout, it seems to be related to the slow starting of the 3G subsystem in an iPhone.

这篇关于iPhone Web服务请求超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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