What you may not grasp is that Cocoa's traditional error handling rules are still in effect:If a method fails and there's only really one failure case for it (trying to convert a non-numeric string to a number, etc.), the method returns nil or false.If an operation fails because of some complex issue with the current state of the computer (no such file, Wi-Fi turned off, etc.), the method emits an NSError. In Swift, NSErrors are handled with the do/try/catch mechanism.If an operation fails because the programmer wrote code that did something invalid (out-of-range array index, etc.), the method fails an assertion or raises an exception, which you should generally allow to crash your app. In Swift, it's not possible to catch exceptions.Creating a fetch request with an inaccurate entity name falls into that third category: failures that can only be the result of programmer error. Such problems are still handled by failing an assertion and crashing your app.
Topic:
Programming Languages
SubTopic:
Swift
Tags: