在崩溃iOS app上调用的方法

Jak*_*kub 0 objective-c ios

问题是我想在我的申请被终止之前发送一些东西到钥匙串(是的,我的意思是终止 - 没有在后台).

我很确定这个AppDelegate方法:

- (void)applicationWillTerminate:(UIApplication *)application
Run Code Online (Sandbox Code Playgroud)

以前在类似的情况下工作.但现在,这种方法从未被调用过.

我正在使用Xcode 5并为iOS 7.0开发

zbM*_*Max 11

我不确定applicationWillTerminate:崩溃时是否触发.

我打电话给didFinishLaunchingWithOptions::

NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);
Run Code Online (Sandbox Code Playgroud)

然后,在appDelegate中,添加:

void uncaughtExceptionHandler(NSException *exception) {
    NSLog(@"CRASH: %@", exception);
    NSLog(@"Stack Trace: %@", [exception callStackSymbols]);
    // Internal error reporting
}
Run Code Online (Sandbox Code Playgroud)

也许你可以通过这种方法将一些东西保存到钥匙串中.