标签:
1.新建GUncaughtExceptionHandler
+ (void)setDefaultHandler
{
NSSetUncaughtExceptionHandler (&UncaughtExceptionHandler);
}
并实现方法
void UncaughtExceptionHandler(NSException *exception)
{
NSArray *arr = [exception callStackSymbols];
NSString*realErr1=[arr objectAtIndex:3];
NSString *error1 = [realErr1 substringFromIndex:51];
NSString * realErr2=[arr objectAtIndex:4];
NSString *error2 = [realErr2 substringFromIndex:51];
NSString * machineName =[Device machineName];
NSString * error=[NSString stringWithFormat:@"%@=====>>>>>%@=====>>>>>%@--%@",machineName,error2,error1,exception.reason];
JSONDAO*jsonDao =[[JSONDAO alloc]init];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat: @"yy-MM-dd"];
NSString*newTime=[dateFormatter stringFromDate:[YlwSingleMode GetCorrectiondate]];
NSDate *lastDay = [NSDate dateWithTimeInterval:-24*60*60 sinceDate:[YlwSingleMode GetCorrectiondate]];
NSString*oldTime=[dateFormatter stringFromDate:lastDay];
[jsonDao updateSoftError:newTime errorlog:error todayDateString:oldTime];
}
2appdelegate调用方法
[GUncaughtExceptionHandler setDefaultHandler];
标签:
原文地址:http://www.cnblogs.com/liaods/p/5169745.html