在启动时检测应用崩溃 [英] Detect App Crash on Launch

查看:107
本文介绍了在启动时检测应用崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到了几个应用程序,这些应用程序检测到上次用于鼓励用户报告错误的应用程序是否崩溃。

I saw a couple applications that detect whether an app crashed the last time it was used to encourage the user to report the bug.

我该怎么做?我尝试了此解决方案,但没有在我的快速项目中使用它...

我想到的一种方法是,每次关闭应用程序时都要保存一些内容,然后在启动应用程序时读取其值,我猜想,当应用程序崩溃时,它将无法再保存任何内容,对吗? br>
但是,这不是很优雅。

How can I do that? I tried this solution, but didn't get it to work in my swift project...
An approach I thought of is to save something each time the app is about to be closed and then read the value when launching the app, I guess when the app crashes then it won't be able to save anything anymore, right?
But, this is not very elegant. Is there a better way for detecting a crash?

预先感谢:)

推荐答案

您可以使用内联闭包在崩溃期间执行日志记录。

You could use an inline closure to perform you logging during crash.

NSSetUncaughtExceptionHandler { exception in
    // Do necessary logging work here
}

SO线程可能对您有所帮助。

这篇关于在启动时检测应用崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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