gpt4 book ai didi

iphone - iOS 模拟器 : Application can't terminate correcly

转载 作者:行者123 更新时间:2023-11-28 22:43:18 24 4
gpt4 key购买 nike

我有一个应用程序,在终止时需要同步 sqlite 数据库的内容。
为了知道应用程序何时终止,我在应用程序委托(delegate)的 applicationWillTerminate: 方法中放置了一个断点。但调试器永远不会走到那里。
我知道两种终止应用程序的方法:

  1. 就像我在 iPhone 中做的那样:持续触摸应用程序图标直到它开始颤抖,然后我点击“x”;
  2. 停止调试器。

这两种方法都不会导致调试器进入我的应用委托(delegate)的 applicationWillTerminate: 方法。
如果我使用第一种方法,我什至会遇到异常:我在这一行收到 SIGKILL:

return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));

即使没有针对该信号的处理程序,模拟器似乎也会启动 SIGKILL。
最后调用的消息是 mach_msg_trap。

最佳答案

来自文档

For applications that do not support background execution or are linked against iOS 3.x or earlier, this method is always called when the user quits the application. For applications that support background execution, this method is generally not called when the user quits the application because the application simply moves to the background in that case. However, this method may be called in situations where the application is running in the background (not suspended) and the system needs to terminate it for some reason.

您可能需要 applicationWillResignActive:

关于iphone - iOS 模拟器 : Application can't terminate correcly,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13859401/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com