Advanced Swift: Error Handling, Episode 5: Handling Objective C Errors | Kodeco, the new raywenderlich.com

App developers deal with errors from UIKit and other Objective-C libraries. Find out how they work with Swift.


This is a companion discussion topic for the original entry at https://www.kodeco.com/1940818-advanced-swift-error-handling/lessons/5

Not entirely sure when it has changed, but it looks like catching an error with associated value as an NSError no longer loses the associated value.

enum FancyError: Error {
  case kazam(String)
}

do {
  throw FancyError.kazam("Help")
}
catch (let error as NSError) {
  dump(error)
}

Outputs:

- __lldb_expr_28.FancyError.kazam("Help") #0
  - super: NSError
    - super: NSObject

Great job on posting your question! Thank you for your positive feedback about the tutorial. It’s always encouraging to hear that our content is helpful.

We will be happy to provide further assistance and address any concerns you may have. We appreciate your participation in our forum!

@rayfix, please your feedbacks would be appreciated.