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!阅读原文】。感谢您的支持!

您可能感兴趣的

iOS 中的 JS 最近主要在研究 iOS 中的 JS 这一块内容,打算从 为什么不能单纯地搞前端、JSCore 的原理和通信机制、OC 底层 Runtime 原理、如何通过 J...
Fastlane 2.88.0 发布,iOS 和安卓自动构建工具... Fastlane 是一个针对于 iOS 和 Android 全方位自动化流程的工具。利用目前支持的工具可以做所有包含自动化和可持续化构建的每个环节,比如单元测试...
iOS关联对象技术原理 iOS 通过 runtime 的 API 可以给分类添加属性,关联属性总共有下边3个 API ///获取某个对象的关联属性 id objc_getAs...
UIImagePickerController in the iOS 7 Status Bar In io7,the status bar on top a view is a nightmare.Fortunally i managed to make ...
Problem with collision images, collision... Hi everyone I'm french so scuse me for my english.My problem is the following: I...