ios - 为什么我可以在 applicationWillTerminate 中运行一段时间(真)?

标签 ios iphone swift

为什么我可以在 应用程序将终止 AppDelegate 中的方法,五秒后它没有停止?

我向控制台打印了一条日志,一分钟后循环仍在运行。

在 Apples 文档中,听起来进程在五秒后被终止。顺便说一句,我的手机在此之后坏了,我需要进行硬重置。

谢谢,我只是好奇

最佳答案

文档说:

If the method does not return before time expires the system may kill the process altogether

文档说大约 5 秒是您的应用不会被杀死的保证时间。

我很确定应用程序迟早会被终止,因为 iOS 有后台进程来确保这一点。

没有暂停的无限循环会消耗 CPU,任何操作系统都很难从中恢复。

关于ios - 为什么我可以在 applicationWillTerminate 中运行一段时间(真)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48645283/

相关文章:

ios - 为什么 Apple 使用此 "if let"代码?

ios - ld : SDK. 使用旧版本的 Swift 语言 (XX) 编译的框架比以前的 ObjC 框架文件(未知 ABI 版本 YYY)

ios - 无法通过 cellForRowAtIndexPath 获取单元格

ios - 不使用 UIImagePickerController 获取 UIImage 元数据

iOS 7 UIStatusBarStyle 在应用程序启动 Bug 期间隐藏状态栏

ios - UITableView 更改时的通知

为什么这个 ScrollView 不显示 subview ?

ios - 使用 URL 启动应用程序,但未调用 OpenUrl

ios - 设置 imageview 角半径

ios - 构建成功后将文本文件安装/导入到物理设备时 Xcode 崩溃 (RangeException)