如果我的应用程序崩溃,如何保存在用户默认 [英] how can i save in userdefaults if my app has crashed

查看:273
本文介绍了如果我的应用程序崩溃,如何保存在用户默认的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Universal-App我有一些问题,应用程序崩溃。我无法重现崩溃的原因,所以我想要至少使应用程序保存,以便它可以重新启动,如果它崩溃。
问题是,如果我的应用程序崩溃,可能会发生,它不能再次启动,由于一些混乱的用户默认值。
所以,如果我可以删除我的用户默认值,我的应用程序崩溃后,开始,用户可以至少使用该应用程序。

In my Universal-App i have some issues where the app crashes. I could not reproduce the cause of the crash so i want at least make the app "save" so that it can restart again if it has crashed. Problem is, if my app crashes, it can happen that it cannot be started again due to some messed up user defaults. So, if i could delete my user defaults after my app has crashed while starting, the user could at least use the app furthermore.

到目前为止目标。现在我只需要知道我可以检测和保存它,当我的应用程序在启动过程中崩溃。

So far for my goals. Now i only need to know how i can detect and save it, when my app has crashed during starting.

我的第一个意图是设置一个标志在用户默认值应用程序崩溃,然后,如果设置标志,重置用户默认值。但我不知道是否 - (void)applicationWillTerminate:(UIApplication *)应用程序

将在我的应用程序崩溃时调用。即使它被调用。如何检测在开始时是否崩溃?

My first intention was to set a flag in user defaults when the app crashes and then ,if the flag is set, to reset the user defaults. But i don't know if - (void)applicationWillTerminate:(UIApplication *)application
will be called when my app crashes. And even if it is called. How can i detect if it crashed during starting?

欢迎任何建议。

问候和thx提前
Maverick1st

Greetings and thx in advance Maverick1st

推荐答案

在每次应用程序启动时设置标志,这样,你知道如果它已经设置,当应用程序启动时,它上次崩溃。

What about setting a flag every time your app starts up and unsetting it when it terminates normally? That way you know if it is already set when the app starts, it crashed last time.

这篇关于如果我的应用程序崩溃,如何保存在用户默认的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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