ios 全局异常捕获,上传服务器

 ios中 xcode  设置全局断点快速定位问题代码所在行, 可以获取异常信息,然后上传服务器,做统计

AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    NSSetUncaughtExceptionHandler(&handler);
    
    return YES;
}


void handler(NSException* exception){
    NSArray *arr= [exception callStackSymbols]; //得到当前调用栈信息
    
    NSString* reason= [exception reason]; // 非常重要,奔溃的原因
    NSString* name= [exception name];  // 异常信息
    NSString* result = [NSString stringWithFormat:@"当期调用栈信息:%@\nCrash的原因:%@\n异常类型:%@\n",arr,reason,name];
    NSLog(@"%@",result);
    
}

异常地点: 


-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
  

       @[][1];
    
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章