Chapter 8. Writing Safer Code with Availability and 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 really felt like a true part of the language. I do have significant experience in C, so I was able to understand how Apple's frameworks received and responded to errors. And to be honest, 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, and so we would have the option of using it. However, it was not in the initial release of Swift. Finally, when Swift 2 was released, Apple did add extra error handling...