Now and again we will still need to deal with NSError. Although the Cocoa APIs are being updated for Swift very rapidly, it's likely that NSError will be with us for some time to come. The good news is that Swift makes it very easy to do.
NSError handling
Anatomy of an NSError
An NSError object has four properties of interest to us here:
- The domain is a String and is used to differentiate groups of error codes
- The error code is an Int, specific to the domain to which it belongs
- The userInfo property is a Dictionary, the values of which are strings that convey any information the throwing function wants to include
- The localizedDescription is a String and is intended for presentation to the user; examples include "You don't have permission...