CHAPTER 26

image

Error Handling

Error Handling Defined

When programs encounter unexpected errors, they behave unexpectedly or stop working altogether. Ideally, programmers would find and fix all bugs before programs are used, but there are some situations were programmers don’t have control of the entire situation. For instance, errors can happen when programs require resources like files or web sites that are no longer present.

The best practice in dealing with situations like this is to add error handling to a program. This means that when an error occurs, the program can recover or gracefully shutdown. NSError is the Foundation class that programmers ...

Get Objective-C Quick Syntax Reference 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.