这是我在应用程序委托中未捕获的异常处理程序,我正在注册它。
void myHandler(NSException * exception)
{
NSError *error;
NSString *stringToWrite = [[NSString alloc]initWithFormat:@"Name:%@ Reason:%@ CallStackSymbols:%@",exception.name,exception.reason,exception.callStackSymbols];
NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject] stringByAppendingPathComponent:@"crashlog.txt"];
[stringToWrite writeToFile:filePath atomically:YES encoding:NSUTF8StringEncoding error:&error];
}
- (BOOL) application : (UIApplication*) application didFinishLaunchingWithOptions : (NSDictionary*) launchOptions {
NSSetUncaughtExceptionHandler(&myHandler);
}
我已启用 iTunes 文件共享以查看崩溃日志
在发布版本崩溃之后..我无法在 iTunes 中找到该文件,而我可以在调试版本中找到它。
(我有数组索引超出范围的错误......来测试它)
有人可以解释一下发生了什么吗