手动崩溃统计

来源:互联网 发布:新的网络安全法 编辑:程序博客网 时间:2024/06/05 12:39

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

//捕获异常操作

    NSSetUncaughtExceptionHandler(handle);

    return YES;

}

//异常回调

void handle(NSException *exception){

    

    NSMutableDictionary *dict = [NSMutableDictionarydictionary];

    

    NSString *name = exception.name;

    NSString *reason = exception.reason;

    NSArray *methodInfo = exception.callStackSymbols;

    dict[@"崩溃名称"]= name;

    dict[@"崩溃原因"]=reason;

    dict[@"崩溃方法"]=methodInfo;

    NSString *document = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES)lastObject]stringByAppendingPathComponent:@"crashNote.plist"];

    [dict writeToFile:document atomically:YES];

    [[NSRunLoopcurrentRunLoop]addPort:[NSPortport] forMode:NSRunLoopCommonModes];

    [[NSRunLoopcurrentRunLoop]run];

  

}


0 0
原创粉丝点击