程序异常退出时发送邮件报告的代码
来源:互联网 发布:开发程序员 编辑:程序博客网 时间:2024/06/05 16:12
转载自:http://www.cocoachina.com/iphonedev/sdk/2011/0705/2999.html
本文转自 随风_1989的博客,利用 NSSetUncaughtExceptionHandler,当程序异常退出的时候,就给指定的邮箱发送邮件,邮件内容包括发生异常时候的详情。代码如下:
void UncaughtExceptionHandler(NSException *exception) {
NSArray *arr = [exception callStackSymbols];
NSString *reason = [exception reason];
NSString *name = [exception name];
NSString *urlStr = [NSString stringWithFormat:@"mailto://suifeng_89@163.com?subject=bug报告&body=感谢您的配合!<br><br><br>"
"错误详情:<br>%@<br>--------------------------<br>%@<br>---------------------<br>%@",
name,reason,[arr componentsJoinedByString:@"<br>"]];
NSURL *url = [NSURL URLWithString:[urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[[UIApplication sharedApplication] openURL:url];
}
然后在delegate文件里面- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions函数里面添加NSSetUncaughtExceptionHandler (&UncaughtExceptionHandler);
这样就大功告成了。
- 程序异常退出时发送邮件报告的代码
- 程序异常退出时发送邮件报告的代码
- 程序异常退出时发送邮件报告的代码
- 程序异常退出时发送邮件报告的代码
- 程序异常退出时发送邮件报告的代码
- 程序异常退出时发送邮件报告的代码
- 程序异常退出时发送邮件报告的代码
- 程序异常退出时发送邮件报告的代码
- 程序异常退出时发送邮件报告的代码
- 程序异常退出时发送邮件报告的代码
- ios程序异常退出时,发送邮件告知
- ios程序异常退出时,发送邮件告知(转)
- ios程序异常退出时,发送邮件告知
- 发送邮件的代码~
- 发送邮件的代码
- 发送邮件的代码
- CRT堆 程序退出时的异常
- 程序异常后通过邮件发送
- 创建没有nib文件的App
- Android 巧用Itent.ACTION_PICK和Intent.ACTION_GET_CONTENT(一)
- Android 巧用Itent.ACTION_PICK和Intent.ACTION_GET_CONTENT(二)
- gcc扩展
- Android 巧用Itent.ACTION_PICK和Intent.ACTION_GET_CONTENT(三)
- 程序异常退出时发送邮件报告的代码
- 黑马程序员------java中的反射,beanutils,注解的应用。
- 些脚本的时,注意事项
- 排序-冒泡排序
- 学习linux心情
- ApiDemo学习 炫酷的 layoutAnimation
- XML Lesson 3
- Android的Activity屏幕切换动画(二)-左右滑动深入与实战
- eclipse的JDK,Tomcat,Ant环境变量设置