【问题标题】:iOS: log to file any crashing exceptioniOS:记录任何崩溃异常
【发布时间】:2017-02-04 06:05:15
【问题描述】:

你们中的任何人都知道如何从 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 中注册任何崩溃异常吗?

【问题讨论】:

    标签: ios exception-handling nsexception


    【解决方案1】:

    您实际上是在使用设置异常处理程序吗? NSSetUncaughtExceptionHandler?

    类似:

    NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);

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

    【讨论】:

    • 我实现了 NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);和作品。但是如何才能将输出记录到日志中呢?
    猜你喜欢
    • 1970-01-01
    • 2013-08-15
    • 1970-01-01
    • 2013-10-08
    • 2011-11-18
    • 2012-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多