zoukankan      html  css  js  c++  java
  • ios获取crash信息

    在程序启动代理内加入如下代码:
    NSString *applicationDocumentsDirectory() 
    {
    return  [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; 
    
    }
    
    void UncaughtExceptionHandler(NSException *exception) 
    { 
    
    NSArray *arr = [exception callStackSymbols]; NSString *reason = [exception reason];
    NSString *name = [exception name];
    
    NSString *path = [applicationDocumentsDirectory() stringByAppendingPathComponent:@"Exception.txt"];
    [urlStr writeToFile:path atomically:YES encoding:NSUTF8StringEncoding error:nil]; 
    }
    
    在- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 里添加如下:
    NSFileManager *fileManager = [NSFileManager defaultManager];
    NSString *path = [applicationDocumentsDirectory() stringByAppendingPathComponent:@"Exception.txt"]; if([fileManager fileExistsAtPath:path]){
    NSString *str = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil]; //读取crash信息 //需要做什么处理在这处理就可以,比如信息上传,
    }
    
    [fileManager removeItemAtPath:path error:nil]; //信息处理完事以后进行删除
    NSSetUncaughtExceptionHandler (&UncaughtExceptionHandler);
  • 相关阅读:
    day21作业
    作业day20
    K8S架构图
    day20 类的继承
    课上随手记
    第一篇CEPH集群的学习
    day19 类的讲解
    Eureka工作原理
    局域网、以太网(标准以太网、工业以太网和实时以太网)与无线局域网
    无线局域网,有线局域网
  • 原文地址:https://www.cnblogs.com/leeAsia/p/3363859.html
Copyright © 2011-2022 走看看