简体   繁体   English

如何为启用了后台功能的iOS应用程序获取applicationWillTerminate通知?

[英]How to get applicationWillTerminate Notification for an iOS App that has Backgrounding Enabled?

So I'm aware that applicationWillTerminate: will not be called if your app supports background execution (unless there's some memory issue), and applicationDidEnterBackground: is called instead. 所以我知道, applicationWillTerminate:不会被调用,如果您的应用支持后台执行(除非有一些内存的问题),并applicationDidEnterBackground:被称为替代。

Inside of the applicationDidEnterBackground: method in the appDelegate, it says 在appDelegate的applicationDidEnterBackground:方法内部,它说

// If your application supports background execution, 
//this method is called instead of applicationWillTerminate: when the user quits.

However, I need to save some entries into a dictionary when the user actually quits the app. 但是,当用户实际退出应用程序时,我需要将一些条目保存到字典中。 I do not want to do this every time the app enters the background though. 我不想每次应用程序进入后台时都执行此操作。 Is there a way to get the termination notification even though my app supports backgrounding? 即使我的应用程序支持后台,有没有办法获得终止通知?

Specifically if the app is force quit by the user, what is some sort of workaround to get a notification of this? 具体来说,如果该应用被用户强行退出,那么有什么解决方法可以得到此通知?

save every time the app enters into the bg. 每次应用进入背景时保存。 the os may THEN kill you without any further warning. 操作系统可能会在没有任何进一步警告的情况下杀死您。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM