当我捕获异常时如何在崩溃日志中留言?

问题描述 投票:0回答:1

当我捕获异常时,我想在崩溃日志中留下一条消息。 NSLog() 有用吗?

iphone
1个回答
0
投票

在 catch 块中写下:

NSLog(@"%@", [e reason]);

其中 e 是 NSError 类的对象。

编辑:

@try {
    //Your Code
}
@catch (NSException * e) {
    NSLog(@"%@", [e reason]);
}

上面的代码找出您的代码之间出现的任何异常。

© www.soinside.com 2019 - 2024. All rights reserved.