下标成员的Facebook SDK错误

我使用Facebook SDKlogin和提取数据在我的最后,但无法解决我面临的问题相关的语法的挑战

func fetchProfile() { let parameters = ["fields": "email, first_name, last_name, picture.type(large)"] FBSDKGraphRequest(graphPath: "me", parameters: parameters).start(completionHandler: { (connection, user, requestError) -> Void in if requestError != nil { print(requestError) return } var email = user["email"] as? String let firstName = user["first_name"] as? String let lastName = user["last_name"] as? String self.nameLabel.text = "\(firstName!) \(lastName!)" var pictureUrl = "" if let picture = user["picture"] as? NSDictionary, let data = picture["data"] as? NSDictionary, let url = data["url"] as? String { pictureUrl = url } }) } 

在这行var email = user["email"] as ? String var email = user["email"] as ? String我得到错误键入任何? 没有成绩单。

尝试这个:

 if let dataDict = user as? [String:AnyObject] { var email = dataDict["email"] as? String let firstName = dataDict["first_name"] as? String let lastName = dataDict["last_name"] as? String //self.nameLabel.text = "\(firstName!) \(lastName!)" var pictureUrl = "" if let picture = dataDict["picture"] as? [String:AnyObject], let data = picture["data"] as? [String:AnyObject], let url = data["url"] as? String { pictureUrl = url } } 

您需要将usertypesAny转换为inputDictionary [String:AnyObject] ,然后只能使用下标从中提取值。