Taylor Simpson
Taylor Simpson

Reputation: 970

Swift 3 created error for Facebook Graph Request

I was asked to update to swift 3 and now my facebook graph request won't compile. It keeps giving me the error Value of type "Any?" has no member 'object'. It throws this error on result.object(forKey: "email") as String!)!. Before swift three it worked properly and never through that error. I am not sure how to fix it as I have not been able to read through all the new documentation.

 let UserEmail = FBSDKGraphRequest.init(graphPath: "me", parameters: ["fields":"email"]).start { (connection, result, error) -> Void in


        let strEmail: String = (result.object(forKey: "email") as? String)!
    }

Upvotes: 1

Views: 508

Answers (1)

Javier Siancas
Javier Siancas

Reputation: 36

You have to convert "result" into a dictionary. For example:

let r: [String: Any]? = result as? [String: Any]

...and continue

Upvotes: 1

Related Questions