NSException方法调用
来源:互联网 发布:免费舆情监控软件 编辑:程序博客网 时间:2024/05/16 12:52
异常调用方法如下:
//######### Method1 ######### [NSException raise:NSInvalidArgumentException format:@"Last name must be Smith"];
该方法抛出异常会导致程序的崩溃。
//######### Method2 ######### NSException *exc = [[NSException alloc]initWithName:@"Value" reason:@"Last name must be Smith" userInfo:nil]; @try { if (![@"Smith1" isEqualToString:@"Smith"]) { @throw exc; } } @catch ( NSException *exception ) { NSLog(@"exception.name = %@" , exception.name); NSLog(@"exception.reason = %@" , exception.reason); } @finally { NSLog(@"@finally"); }
该方法可以捕获异常,并根据异常做相应处理。
0 0
- NSException方法调用
- NSException
- NSError && NSException
- NSError and NSException
- ios NSException 异常处理
- Foundation框架 - NSException类
- NSException异常处理
- NSError和NSException区别
- 被遗忘的NSException
- OC : NSException (崩溃)
- NSException 程序崩溃日志
- 使用字面量的方法创建一个dictionary报错:libc++abi.dylib: terminating with uncaught exception of type NSException
- Objective-C - 异常处理(NSException)
- iOS NSException 配套使用方案
- 方法调用
- 方法调用
- 方法调用
- 方法调用
- acm 3 1003 最大递增子段和
- hibernate annotation注解方式来处理映射关系
- 初步接触eclips和异常排查
- Ehcache Memcache Redis 初步(二)
- 网络数据包收发流程(一):从驱动到协议栈
- NSException方法调用
- DecimalFormat的用法 Java小数(float、dobule)格式化
- 关于MFC控件的一些问题
- Android页面布局
- hibernate的hql查询语句总结
- 结构体内存字节对齐
- Studying Method
- 【HDU】 1299 Diophantus of Alexandria
- 单调队列(基础题) HDU3706 Second My Problem First