H. Lamb H. Lamb - 1 year ago 381
Swift Question

xcode 8 value of type 'Error' has no member 'userinfo'

I just upgraded to Xcode 8 and am already getting errors which cause the build to fail. I'm very new to swift, please help.

enter image description here

What should I change this to? Thanks


Apart from this error i also got the following:

PFUser.logInWithUsername(inBackground: usernameTextField.text!, password: passwordTextField.text!, block: { (user, error) -> Void in


if user != nil {


} else {

let convertedError = error! as NSError

//if let errorString = convertedError["error"] as? String {
errorMessage = errorString
self.displayAlert("Login failed", message: errorMessage)


for the // line I got "type NSError has no subscript members" error. I tried bridging it to NSError but it does not work this time. What should i do? thanks a lot

Answer Source

First of all, post the code (text) rather than a screenshot.

In Swift 3 NSError has been replaced in many API with more generic Swift Error protocol which has no userInfo dictionary. Bridge cast the object to NSError

if let errorString = (error! as NSError).userInfo....
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download