Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Two direct subclasses of NSObject are used in Cocoa and Objective-C to handle unexpected events. They have different structures and different uses. Exceptions and errors are described in the following sections. After that, you look inside the classes that implement them (NSException and NSError).
Exceptions are typically thrown (or raised) as the app runs. These include conditions such as low (or no) memory, a communication link that does not exist (or that has suddenly disappeared), and the like. They also include conditions such as attempting to access a non-existent object or variable whether it is through an invalid array subscript or a dangling pointer. They also can arise from passing invalid arguments into methods.