A conversation started on twitter yesterday surrounding the inability of subscripts to throw errors. It was begun by @krzyzanowskim and gave me the opportunity to think even further about the approach to error handling I am employing in Aldwych 2.0 (a JSON parser for Swift). Standard approach My standard approach is to follow the Swift standard library way of doing things as much as possible. The core example being to throw errors when something user-led might not be possible: e.g. a file chosen is of the wrong type or the data in the file is corrupted, or the data simply doesn't parse. This logic means that NSJSONSerialization has throwing methods as standard for creating objects from JSON and for creating JSON from objects. While NSData goes halfway and has a choice of failable initializers and throwing intializers in iOS 9 (Xcode 7 beta 4). For example: init(contentsOfURL url: NSURL, options readOptionsMask: NSDataReadingOptions) throws and init?(contentsOfURL ur
Technology tips for writers, editors, designers, illustrators, programmers and publishers, and now Retro Gamers.