Chapter 8. Writing Safer Code with Error Handling
When I first started writing applications with Objective-C, one of the most noticeable deficiencies was the lack of exception handling. 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 have significant experience with C, so I was able to understand how Apple frameworks received and responded to errors, and, to be honest, in some cases, I actually preferred this method, even though I had grown accustomed to exception handling with Java and C#. When Swift was first introduced, I was hoping that Apple would put true error handling into the language so we would have the option of using it; however, it was not in the initial release of Swift. When Swift 2 was released, Apple added additional error handling to Swift...