保证IOS程序始终不死
2016-07-26 16:36
453 查看
void handleException(NSException *exception)
{
[[UIApplication sharedApplication].delegate performSelector:@selector(handle)];
}
- (void)handle
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"哈哈" message:@"傻逼了把" delegate:self cancelButtonTitle:@"好的"
otherButtonTitles:nil, nil];
[alertView show];
// 重新启动RunLoop
[[NSRunLoop currentRunLoop] addPort:[NSPort port] forMode:NSDefaultRunLoopMode];
[[NSRunLoop currentRunLoop] run];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSLog(@"-------点击了好的");
// exit(0);
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//
设置捕捉异常的回调
NSSetUncaughtExceptionHandler(handleException);
return YES;
}
重启一个RunLoop循环保证程序不死
{
[[UIApplication sharedApplication].delegate performSelector:@selector(handle)];
}
- (void)handle
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"哈哈" message:@"傻逼了把" delegate:self cancelButtonTitle:@"好的"
otherButtonTitles:nil, nil];
[alertView show];
// 重新启动RunLoop
[[NSRunLoop currentRunLoop] addPort:[NSPort port] forMode:NSDefaultRunLoopMode];
[[NSRunLoop currentRunLoop] run];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSLog(@"-------点击了好的");
// exit(0);
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//
设置捕捉异常的回调
NSSetUncaughtExceptionHandler(handleException);
return YES;
}
重启一个RunLoop循环保证程序不死
相关文章推荐
- iOS 获取设备类型和系统信息
- (枚举+注意格式)HDU1017 A Mathematical Curiosity
- [置顶] iOS录音方法实用详解(配Demo下载)
- Masonry -- 使用纯代码进行iOS应用的autolayout自适应布局
- ios强制横屏
- iOS开发之网银在线支付快捷支付商户接口规范
- [编写高质量iOS代码的52个有效方法](六)协议与分类
- 如何利用iOS多核高效遍历数组.
- iOS中TableView在Nav存在下发生下移的问题
- iOS中游客模式的自动登录“正确姿势”
- iOS中修改vc标题的方法及区别
- KVC和runtime字典转模型
- iOS字符串中特殊字符的编码与解码
- ios学习笔记——代理设计模式
- 判断键盘是否显示
- 给label添加点击方法
- 蒲公英内测平台使用说明
- ios 最简单的视频播放器
- IOS button背景颜色状态设置
- iOS开发-- 常见坑(极光推送这只标签别名失败)