码迷,mamicode.com
首页 > 其他好文 > 详细

iphone 异常捕获处理

时间:2016-09-06 01:02:00      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:

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://XXX@XXX.com?subject=bug报告&body=感谢您的配合!<br><br><br>"
 6                         "错误详情:<br>%@<br>--------------------------<br>%@<br>---------------------<br>%@",
 7                         name,
 8                         reason,
 9                         [arr componentsJoinedByString:@"<br>"]];
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 }
技术分享

iphone 异常捕获处理

标签:

原文地址:http://www.cnblogs.com/LiLihongqiang/p/5844123.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!