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);
  • 相关阅读:
    软件工程个人作业01
    学习进度一(2017/12/2)
    课程增加功能(java web)
    剑指offer-把数组排成最小的数
    论文-Edge Boxes
    论文-Selective Search
    剑指offer-机器人的运动范围
    leetcode-539-Minimum Time Difference
    Leetcode-543-Diameter of Binary Tree
    论文-SSD-Single Shot MultiBox Detector
  • 原文地址:https://www.cnblogs.com/leeAsia/p/3363859.html
Copyright © 2011-2022 走看看