iphone - 如何正确处理异常情况(信号?)

发布于 2024-09-01 15:36:15 字数 337 浏览 2 评论 0原文

在我的 iPhone 应用程序中,我想提供某种应用程序终止处理程序,该处理程序将在应用程序终止之前执行一些最终工作(删除一些敏感数据)。

我想尽可能多地处理终止情况:
1) 用户终止应用
2) 设备电量耗尽
3) 系统由于某种原因终止应用程序(例如内存不足或应用程序冻结)
4) 应用程序崩溃(EXC_BAD_ACCESS 或 SIGSEGV)

任何其他异常情况?
实现此目的的最佳方法是什么(例如,在情况 2 中调用 applicationWillTerminate 方法)?
是否可以在信号处理程序中进行清理(包括 iPhone 安全框架调用)?

问候

In my iphone app, I want to provide some sort of app termination handler that will do some final work (delete some sensitive data) before the application terminates.

I want to handle as much of the termination situations as possible:
1) User terminates the app
2) The device runs out of battery
3) The system terminates the app due to some reason (e.g. out of memory or app freeze)
4) Application crashes (EXC_BAD_ACCESS or SIGSEGV)

Any other exceptional situation ?
What is the best way to achieve this (e.g. is applicationWillTerminate method called in situation 2) ?
Is it possible to do the cleanup in a signal handler (includes iPhone Security framework calls) ?

regards

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

那请放手 2024-09-08 15:36:15

这篇及时的帖子将帮助您从 4) 开始。

您知道您的应用程序何时将从您的应用程序委托终止,并且您可以监听电池变化的通知,请参阅 UIDevice

This timely post will help you with 4) to start with.

You know when your app is going to terminate from your app delegate and you can listen for notifcations to battery changes, see UIDevice.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文