Application detection broke during load / last time it was run?

综合技术 2018-02-16 阅读原文

I would like for my app to reset to standard settings if it crashed during startup. Preferably also if it crashed last time it was run.

EDIT: Crittercism has a crittercismDidCrashOnLastLoad method, but it only handles the case of crashing during load. It didn't work properly in the version of the library I used, but this has since been fixed.

Suggestions?

Make 2 functions in your AppDelegate.m
file:

void HandleException(NSException *exception) {
    NSLog(@"App crashing with exception: %@", exception);
    //Save somewhere that your app has crashed.
}

void HandleSignal(int signal) {
    NSLog(@"We received a signal: %d", signal);
    //Save somewhere that your app has crashed.
}

Then in your -(BOOL)application:didFinishLaunchingWithOptions
before anything else put:

NSSetUncaughtExceptionHandler(&HandleException);

struct sigaction signalAction;
memset(&signalAction, 0, sizeof(signalAction));
signalAction.sa_handler = &HandleSignal;

sigaction(SIGABRT, &signalAction, NULL);
sigaction(SIGILL, &signalAction, NULL);
sigaction(SIGBUS, &signalAction, NULL);
Hello, buddy!

责编内容by:Hello, buddy!阅读原文】。感谢您的支持!

您可能感兴趣的

Kotlin Data Class In this tutorial, we’ll look atKotlin Data Class. If you haven’t read theKotlin Classes post, we recommend you to do so...
Image not displayed on an image table here the issue is i'm getting a array of images from server ,but i'm not able to displayed image on ImageView .Below...
iOS设备中的推送(四):本地推送(闹钟) ###推送的介绍 iOS 设备推送中除了远程推送几乎必不可少外,本地推送在一些情况下同样有着其特殊的作用。本地推送最常用的就是在软件中让用户自己设置一个提醒,比如闹钟,备忘提醒等。今天我们就以一个闹钟举例来说明一下本地推送的应用。 ###本...
Chat with your Raspi – SwiftyLinkerKit+NIO If you are like the ARI, you own some Raspberry Pi’s doing some serious work. But you never actually used the Pi’s ...
Clang 之旅–实现一个自定义检查规范的 Clang 插件... 前言 在 Clang 之旅系列文章 开篇 的时候,我说到过自己接触 Clang 的直接原因就是想实现一个自定义的检查需求:是否有办法在编译阶段检查某个方法的参数与返回值的类型相同,如果类型不一致的话能抛出编译错误的提示。现在我已经根据...