iphone 异常捕获处理

iphone 异常捕获处理

复制代码
 1 void UncaughtExceptionHandler(NSException *exception) {
 2     NSArray *arr = [exception callStackSymbols];
 3     NSString *reason = [exception reason];
 4     NSString *name = [exception name];
 5     NSString *urlStr = [NSString stringWithFormat:@"mailto://[email protected]?subject=bug报告&body=感谢您的配合!


" 6 "错误详情:
%@
--------------------------
%@
---------------------
%@", 7 name, 8 reason, 9 [arr componentsJoinedByString:@"
"]]; 10 NSURL *url = [NSURL URLWithString:[urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; 11 [[UIApplication sharedApplication] openURL:url]; 12 }
复制代码

然后在程序启动中加入异常捕获回调

复制代码
1 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
2 {
3     // Override point for customization after application launch.
4     NSSetUncaughtExceptionHandler (&UncaughtExceptionHandler);
5     return YES;
6 }
复制代码

转载于:https://www.cnblogs.com/LiLihongqiang/p/5844123.html

你可能感兴趣的:(iphone 异常捕获处理)