您的位置:首页 > 移动开发 > IOS开发

iOS捕获系统异常

2015-09-17 10:32 399 查看
// 提交异常Log信息
void UncaughtExceptionHandler(NSException *exception) {

// 异常Log信息
NSString *errorStr = [NSString stringWithFormat:@"错误详情:%@\n%@\n%@",
[exception name], [exception reason], [[exception callStackSymbols] componentsJoinedByString:@"\n"]];

// 提交到服务器
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:device_exception, Host]];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setRequestMethod:@"POST"];
[request setPostValue:errorStr forKey:@"exception"];
[request setPostValue:@"1" forKey:@"device"];
[request startSynchronous];

}

// AppDelegate中调用
NSSetUncaughtExceptionHandler(&UncaughtExceptionHandler); //设置异常Log信息的处理
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: