NSError和NSException区别
来源:互联网 发布:java中最难的是什么 编辑:程序博客网 时间:2024/06/05 21:58
NSError和NSException区别
Exception是程序级别的错误,在catch的时候如果没有捕获会crash
Error是用户级别的错误
Exception:
NSException is used to implement exception handling and contains information about an exception. An exception is a special condition that interrupts the normal flow of program execution. Each application can interrupt the program for different reasons. For example, one application might interpret saving a file in a directory that is write-protected as an exception. In this sense, the exception is equivalent to an error. Another application might interpret the user’s key-press (for example, Control-C) as an exception: an indication that a long-running process should be aborted.
Two distinct types of problems can arise while an iOS or OS X application is running. Exceptions represent programmer-level bugs like trying to access an array element that doesn’t exist. They are designed to inform the developer that an unexpected condition occurred. Since they usually result in the program crashing, exceptions should rarely occur in your production code.
NSError
Every program must deal with errors as they occur at runtime. The program, for example, might not be able to open a file, or perhaps it cannot parse an XML document. Often errors such as these require the program to inform the user about them. And perhaps the program can attempt to get around the problem causing the error.
On the other hand, errors are user-level issues like trying load a file that doesn’t exist. Because errors are expected during the normal execution of a program, you should manually check for these kinds of conditions and inform the user when they occur. Most of the time, they should not cause your application to crash.
参考地址:
地址一:
http://rypress.com/tutorials/objective-c/exceptions
地址二:
http://stackoverflow.com/questions/11100951/nsexception-and-nserror-custom-exception-error
地址三 :
https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSException_Class/index.html
地址四:
https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSError_Class/
https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ErrorHandlingCocoa/ErrorHandling/ErrorHandling.html#//apple_ref/doc/uid/TP40001806
- NSError和NSException区别
- NSError && NSException
- NSError和NSException的几点说明
- NSError and NSException
- NSException
- NSError
- NSError
- NSError
- NSError
- NSError使用
- NSError错误信息
- 错误信息 NSError
- 错误信息 NSError
- 错误信息 NSError
- NSError详解
- 错误信息 NSError
- 关于NSError
- NSError errorcode
- 回调函数
- Swift使用友盟分享
- angularjs学习总结 详细教程
- java调用dll文件处理过程
- runtime-ios
- NSError和NSException区别
- 在Servlet使用getServletContext()获取ServletContext对象出现java.lang.NullPointerException(空指针)异常的解决办法
- 袁腾飞——春秋战国
- 集合随机抽取与排序(双色球)
- multicastSocket实现单播组播 局域网通信
- 城市列表-根据拼音首字母排序
- Linux——文件操作
- Logistic Regression 损失函数理解
- hadoop2.7.2安装部署教程