iOS捕获系统异常

时间:2015-09-17 11:47:36   收藏:0   阅读:109
// 提交异常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信息的处理

 

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

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!