I'm initializing an AVCaptureDeviceInput. In Swift 2 rather than getting an NSError variable you catch an error with a do-try-catch sandwich. However I don't see how to get the NSError inside the catch part. The recommendation given on Apple's developer forum does not indicate how you can access the NSError.
Can someone enlighten me?
This worked for me:
var error: NSError?
do {
request.HTTPBody = try NSJSONSerialization.dataWithJSONObject(jsonString, options: [])
} catch let error1 as NSError {
error = error1
request.HTTPBody = nil
}
Hope this will be helpful
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With