如果一个函数执行时间太长,iPhone是否超时? [英] Does the iPhone timeout if a function takes too long to execute?

查看:155
本文介绍了如果一个函数执行时间太长,iPhone是否超时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个函数,其中我使用可可的Url对象从Web获取外部资源。它在模拟器上正常工作,但偶尔在设备本身失败(这是一个谷歌查询,所以资源显然确实存在)。这使我相信硬件上有一些内部超时障碍,但没有读到这样的障碍存在与否。

I have a function in which I get en external resource from the web using cocoa's Url object. And it works fine on the simulator, but occasionally fails on the device itself (it's a google query so the resource obviously does exist). Which leads me to believe that there is some internal timeout barrier on the hardware, but haven't read that such a barrier exists or not.

任何人遇到类似的问题吗?

Anyone else encountered similar issues? Or knows if the timeout is documented or can be changed?

推荐答案

iPhone强加了应用程序启动的超时时间。因此,如果在applicationDidFinishLaunching中执行大量处理:例如,应用程序将被终止,并生成崩溃日志。不幸的是,我没有发现在官方文档中没有提到它。

iPhone imposes a timeout for application launch. So if you perform an extensive processing in applicationDidFinishLaunching: for instance, the application will be terminated and a crash log will be produced. Unfortunately I've found no mention of it in the official documentation.

启动过程完成后,我不知道任何超时限制函数执行时间。我已经尝试在设备上睡眠30秒在主线程,它工作正常。

After the launch process has completed, I'm not aware of any timeouts that limit function execution time. I've tried it on the device with putting sleep for 30 seconds in the main thread and it works fine.

这篇关于如果一个函数执行时间太长,iPhone是否超时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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