Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Hour 21. Handling Exceptions > Introducing the Exception and Error Classes

Introducing the Exception and Error Classes

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).

Using Exceptions

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.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial