码迷,mamicode.com
首页 > 移动开发 > 详细

iOS捕获系统异常

时间:2015-09-17 11:49:38      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:

// 提交异常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信息的处理

 

iOS捕获系统异常

标签:

原文地址:http://www.cnblogs.com/rgshio/p/4815554.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!