NSError and NSException

标签: ioscocoa
2044人阅读 评论(0) 收藏 举报
分类:

NSError is designed for non-fatal, recoverable errors. The problems that are designed to be captured by an NSError are often user errors (or are errors that can be presented to the user), can often be recovered from (hence -presentError: and NSErrorRecoveryAttempting), and are usually expected or predictable errors (like trying to open a file that you don't have access to, or trying to convert between incompatible string encodings).

NSException is designed for potentially fatal, programmer errors. These errors are designed to signify potential flaws in your application where you have not correctly checked the pre-conditions for performing some operations (like trying to access an array index that is beyond its bounds, or attempts to mutate an immutable object). The introduction to the Exception Programming Guide explains this a little bit

2
1

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:741778次
    • 积分:11601
    • 等级:
    • 排名:第1315名
    • 原创:333篇
    • 转载:90篇
    • 译文:0篇
    • 评论:85条
    博客专栏
    文章分类
    最新评论