Exceptions and the Cocoa Frameworks

Exceptions in Cocoa are represented by objects of the NSException class, which is part of the Foundation framework. The methods of this class allow you to create exception objects, raise (throw) exceptions with them, and get the call return addresses related to an exception. The attributes of an NSException object are the following:

You may extract the information in an exception object and, if appropriate, present to the user in an alert dialog, perhaps using an NSError object. See Handling Exceptions for information on this subject.

The Cocoa frameworks require that all exceptions be instances of NSException or its subclasses. Do not throw objects of other types.

The Cocoa frameworks are generally not exception-safe. The general pattern is that exceptions are reserved for programmer error only, and the program catching such an exception should quit soon afterwards.