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);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…