Name

NSException — Mac OS X 10.0

Synopsis

This class implements the Foundation framework’s exception-handling system. Exceptions are used in Cocoa as a mechanism to deal with special conditions in the execution of a program that may require special handling. Clients can use NSException objects to raise exceptions (creating a special condition), as well as to retrieve information about an exception. For details on exception handling, see Chapter 2.

image with no caption

@interface NSException : NSObject <NSCoding, NSCopying>
                                  // Convenience Constructors
   + (NSException *)exceptionWithName:(NSString *)name 
                                 reason:(NSString *)reason 
                                 userInfo:(NSDictionary *)userInfo;
                                  // Initializers
   - (id)initWithName:(NSString *)aName 
                                 reason:(NSString *)aReason 
                                 userInfo:(NSDictionary *)aUserInfo;
                                  // Class Methods
   + (void)raise:(NSString *)name 
                                 format:(NSString *)format 
                                 arguments:(va_list)argList;
   + (void)raise:(NSString *)name 
                                 format:(NSString *)format, ...;
                                  // Instance Methods
   - (NSString *)name;
   - (void)raise;
   - (NSString *)reason;
   - (NSDictionary *)userInfo;
                                  // Methods Implementing NSCoding
   - (void)encodeWithCoder:(NSCoder *)aCoder;
   - (id)initWithCoder:(NSCoder *)aDecoder;
                                  // Methods Implementing NSCopying
   - (id)copyWithZone:(NSZone *)zone;

Get Cocoa in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.