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.


Make 2 functions in your AppDelegate.m

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:


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事件分发机制与实践 iOS事件的传递与响应是一个重要的话题,网上谈论的很多,但大多讲述并不完整,本文将结合苹果官方的文档对事件的传递与响应原理及应用实践做一个比较完整的总结。文章将依次介绍下列内容: 事件的传递机制 事件的响应机制 事件...
iOS屏幕旋转及其基本适配方法 屏幕旋转示例.jpeg 前段时间抽空总结了一下iOS视频播放的基本用法,发现这其中还有一个我们无法绕过的问题,那就是播放界面的旋转与适配。的确,视频播放与游戏类型的App经常会遇到这个的问题。由于至今接手的项目中不...
Stack View 自定义间隙 翻译自: Apple 在 iOS9 引入了 StackView,使用它可以减少约束的数量,让使用 AutoLayout 更加容...
iOS: 如何正确的绘制1像素的线 iOS 绘制1像素的线 一、Point Vs Pixel iOS中当我们使用Quartz,UIKit,CoreAnimation等框架时,所有的坐标系统采用Point来衡量。系统在实际渲染到设置时会帮助我们处理Point到Pix...
The MFC state is invalid when the DLL is called vi... i'm fighting with MFC and dynamicly linking DLLs with LoadLibrary. It seems that I cannot get the MFC state right when t...