我想使用Facebook
登录并从Facebook
帐户获取用户数据。这是我的登录按钮代码:
func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!)
{
FBSDKGraphRequest.init(graphPath: "me", parameters: ["fields":"first_name, last_name"]).start { (connection, result, error) -> Void in
let strFirstName: String = (result.objectForKey("first_name") as? String)!
let strLastName: String = (result.objectForKey("last_name") as? String)!
self.lblName.text = "Welcome, \(strFirstName) \(strLastName)"
}
}
我在这些方面遇到错误:
let strFirstName: String = (result.objectForKey("first_name") as? String)!
let strLastName: String = (result.objectForKey("last_name") as? String)!
错误:
类型的价值'任何?'没有会员' objectForKey'
我正在使用Swift 3
。我没有得到什么解决方案..?
提前致谢。