< Previous PageNext Page > Hide TOC

Predefined Exceptions

Cocoa predefines a number of generic exception names to identify exceptions that you can handle in your own code or even raise and re-raise. You can also create and use custom exception names. The generic exception names are string constants defined in NSException.h and documented in the "Types and Constants" part of Foundation Framework Reference. These constants include the following:

In addition to the generic exception names, some subsystems of Cocoa define their own exception names, such as NSInconsistentArchiveException and NSFileHandleOperationException. These are also documented in the "Types and Constants" part of Foundation Framework Reference

You can identify caught exceptions in your exception handler by comparing the exception's name with these predefined names. Then you can either handle the exception or, if it isn't one you are interested in, re-raise it. Note that all predefined exceptions begin with the prefix "NS", so you should avoid using the same prefix when creating new exception names.



< Previous PageNext Page > Hide TOC


© 2002, 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-10-02)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.