Objective-C: Assertion vs. Exception vs. Error

In Cocoa, when should I use NSAssert, NSException, NSError?

Here's what I've been thinking:

NSAssert - When creating any client program used for the programmers own benefit to double check rules, conventions, assumptions, or pre-conditions and post-conditions?

NSException - When creating a third-party library for the benefit of other programmers that use the library, so that they immediately know when an input is invalid?

NSError - When interfacing with an external system to get data like a file, database, or web service that isn't guaranteed to give me a result?

79
задан Michael Currie 7 September 2015 в 01:45
поделиться