NSURLConnection在iOS 6上超时,但在iOS 5上没有 [英] NSURLConnection timing out on iOS 6 but not on iOS 5

查看:97
本文介绍了NSURLConnection在iOS 6上超时,但在iOS 5上没有的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用NSURLConnection的应用程序,并且在iOS 5上运行得很好,现在相同的代码在iOS 6中即时超时。

I have an app that used NSURLConnection and worked just fine on iOS 5, now that same code is getting an instant timeout in iOS 6.

任何关于什么的想法可能在5.1和6.0的两个版本之间发生了变化?

Any idea on what might have changed between the two releases of 5.1 and 6.0?

推荐答案

在iOS 5.1及以前的版本中,超时间隔设置为由于另一个原因,我们忽略了构造请求主体。

In iOS 5.1 and previous versions the timeout interval being set when the request body was constructed was ignored for one reason of another.

iOS 6似乎要注意并且更准确地说明超时间隔因此只需确保将间隔设置为一个足够大的值,以便有时间让请求完成。

iOS 6 seems to pay attention and is more precise about the timeout interval so just make sure to set the interval to a value large enough to allow time for the request to complete.

NSMutableURLRequest *request=[[NSMutableURLRequest alloc]
                              initWithURL:[NSURL URLWithString: url]
                              cachePolicy:NSURLRequestReloadIgnoringCacheData
                              timeoutInterval:60.0];

这篇关于NSURLConnection在iOS 6上超时,但在iOS 5上没有的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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