Another option to access code and domain properties in Swift 3 Error types is extending it as follow:
extension Error {
var code: Int { return (self as NSError).code }
var domain: String { return (self as NSError).domain }
}
More Related Contents:
- Swift 3 incorrect string interpolation with implicitly unwrapped Optionals
- How to provide a localized description with an Error type in Swift?
- Waiting until the task finishes
- round trip Swift number types to/from Data
- What are the new “for”, “at”, “in” keywords in Swift3 function declarations?
- The “++” and “–” operators have been deprecated Xcode 7.3
- How to apply the type to a NSFetchRequest instance?
- Shuffle array swift 3
- What is a good example to differentiate between fileprivate and private in Swift3
- Swift 3 for loop with increment
- Swift 3 first parameter names
- Express for loops in swift with dynamic range
- What happened to the UIView?() constructor in Swift 3.0?
- Swap rootViewController with animation?
- Knowing where retain cycles are and removing them
- Whither dispatch_once in Swift 3?
- Add Local Notification in iOS 10 – Swift 3
- Why is ‘nil’ not compatible with ‘UnsafePointer’ in Swift 3?
- “classname has no member functionname” when adding UIButton target
- Xcode 8 / Swift 3 : Simple UIPicker code not working
- Make code with Firebase asynchronous
- try, try! & try? what’s the difference, and when to use each?
- print without newline in swift
- Convert Swift Array to Dictionary with indexes [duplicate]
- Swift3 optionals chaining in IF conditions bug?
- How can I switch views programmatically in a view controller? (Xcode, iPhone)
- How do you enumerate OptionSetType in Swift?
- How to get user home directory path (Users/”user name”) without knowing the username in Swift3
- AVAudioEngine downsample issue
- Whats the Swift animate WithDuration syntax?