使用NSAssert进行代码调试
来源:互联网 发布:abp zero 源码 编辑:程序博客网 时间:2024/05/18 02:12
开发ios程序时调试的好帮手---NSAssert()函数
代码如下: NSAssert(x!=0,@"x must not be zero");
在表达式“x!=0”不成立时,程序就会抛出异常,并显示自定义的消息"x must not be zero",并同时显示出错的文件、代码和调用函数等信息,是一个程序追踪的很好手段。
假设x!=0,不满足要求就提示reason-x must not be zero
assert 是C里面的宏。用于断言。
NSAssert 只能在Objective-c里面使用。是assert的一个扩充。能捕获assert类异常及打印一些
可读的日志。而assert只是让app crash(abort).
参考 : http://stackoverflow.com/questions/6616347/nsassert-vs-assert-which-do-you-use-and-when
The basic difference between an NSAssert and a regular assert is that an NSAssertraises an exception when it fails while an assert just crashes the app. NSAssert also lets you supply fancier error messages and logs them. Practically, I really don't think there's much difference between the two--I can't think of a reason to handle an exception thrown by an assertion. (To split hairs, I think NSAssert usually involves less typing because you don't have to includeassert.h, but that's neither here nor there.)
http://www.wahenzan.com
- 使用NSAssert进行代码调试
- NSAssert使用 调试
- iOS 使用断言NSAssert()调试程序错误
- 使用NSAssert()和NSParameterAssert调试程序
- 使用断言NSAssert()调试程序错误
- iOS --- 使用NSAssert来调试程序
- 使用断言NSAssert()调试程序错误
- 使用断言NSAssert()调试程序错误
- iOS 使用断言NSAssert()调试程序错误
- 代码中断言的使用NSAssert、NSParameterAssert
- 使用NSAssert
- NSAssert使用
- 使用断言NSAssert()和NSParameterAssert调试程序错误
- [IOS 开发] 使用断言NSAssert()调试程序错误
- 使用断言NSAssert()和NSParameterAssert调试程序错误
- iOS 断言 NSAssert的使用 调试程序错误
- 使用断言NSAssert()和NSParameterAssert调试程序错误
- ios NSAssert调试程序
- iOS 运行时添加属性和方法
- JAVA 打印,自定义纸张大小
- Linux中ELF格式文件介绍
- android反编译apk后,java文件中出现的一些类似乱码的问题
- Scramble String
- 使用NSAssert进行代码调试
- vj2006(区间dp)
- 使用JMAP dump及分析dump文件
- 胡博君浅谈Java中的匿名对象
- UIScrollView实现图片放大、缩小
- Ajax长连接
- jmap -heap 命令详解
- 初步了解Google Blink
- 如何解决easyui-datagrid分页组件中文显示的问题