NSURLConnection timing out on iOS 6 but not on iOS 5

风流意气都作罢 提交于 2019-12-05 01:33:51

问题


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.

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


回答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 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];


来源:https://stackoverflow.com/questions/12565740/nsurlconnection-timing-out-on-ios-6-but-not-on-ios-5

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!