iPhone SDK: URL request not timing out

こ雲淡風輕ζ 提交于 2019-11-30 15:45:34

A representative from Apple has divulged that SDK 3.0 and later enforce a minimum timeout of (you guessed it) four minutes:

https://devforums.apple.com/thread/25282

If you try to set a timeout value of less than 240 seconds, it gets clamped up to 240. If you need a shorter timeout, I cast my vote for St3fan's solution.

If you want better timeout management on http requests using NSURLConnection then it is much better to run the request asynchronous together with an NSTimer that can cancel the NSURLConnection when it fires because the timeout period expired.

This also means you don't have to deal with threads, which is generally a good idea. Async event (runloop) based operations are the way to go in 99.9% of the cases on the iPhone.

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