Chapter 7. Writing Safer Code with Availability and Error Handling

When I first started writing iOS and OS X applications with Objective-C, one of the most noticeable deficiencies was the lack of exception handling when working with the Cocoa and Cocoa Touch frameworks. Most modern programming languages such as Java and C# use try-catch blocks or something similar to handle exceptions. While Objective-C did have the try-catch block, it wasn't used within the Cocoa frameworks themselves and it never felt like a true part of the language. I do have significant experience with C, so I was able to understand how the Cocoa and Cocoa Touch frameworks received and responded to errors, and to be honest, I actually preferred this method, even though I ...

Get Mastering Swift 2 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.