- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//捕获异常操作
NSSetUncaughtExceptionHandler(handle);
return YES;
}
//异常回调
void handle(NSException *exception){
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
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];
[[NSRunLoop currentRunLoop]addPort:[NSPort port] forMode:NSRunLoopCommonModes];
[[NSRunLoop currentRunLoop]run];
}