iOS:记录任何崩溃异常

iOS:记录任何崩溃异常

问题描述:

你们谁都知道我怎么能从iOS应用程序记录任何崩溃异常?iOS:记录任何崩溃异常

我逼崩溃在我的viewController:

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    NSArray *myArray = [NSArray new]; 
    NSLog(@"%@", [myArray objectAtIndex:0]); 
} 

,我试图捕捉在控制台中坠毁在我的AppDelegate:

void uncaughtExceptionHandler(NSException *exception) { 
    NSLog(@"CRASH: %@", exception); 
    NSLog(@"Stack Trace: %@", [exception callStackSymbols]); 
} 

void SignalHandler(int sig) { 
    NSLog(@"CRASH: %d",sig); 
} 

但这并没有工作。你们谁都知道如何在iOS中注册任何崩溃的异常?

您是否真的使用 NSSetUncaughtExceptionHandler来设置异常处理程序?

是这样的:

NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);

https://developer.apple.com/reference/foundation/1409609-nssetuncaughtexceptionhandler

+0

我实现NSSetUncaughtExceptionHandler(&的UncaughtExceptionHandler);和工作。但如何记录输出日志? – user2924482