我正在尝试在我的应用中登录fb后检索电子邮件ID。但是当我尝试从结果中获取值时,我收到错误。
错误是:Type 'Any?' has no subscript members
。
func fetchProfile()
{
print("Fetch Profile")
let parameters = ["fields": "email, first_name, last_name, picture.type(large)"]
FBSDKGraphRequest(graphPath: "me", parameters: parameters).start { (connection, result, error) in
let email = result["email"] as? String //Type 'Any?' has no subscript members error occurs here.
}
}
答案 0 :(得分:6)
更改此
let email = result["email"] as? String
进入
guard let resultNew = result as? [String:Any]
let email = resultNew["email"] as! String
完整答案
let parameters = ["fields": "email, first_name, last_name, picture.type(large)"]
FBSDKGraphRequest(graphPath: "me", parameters: parameters).start { (connection, result, error) in
guard let resultNew = result as? [String:Any]
let email = resultNew["email"] as! String
}
答案 1 :(得分:2)
适用于Swift 3 。
更改此内容 - >
Private Sub Workbook_SheetSelectionChangeEnable(ByVal Sh As Object, ByVal Target As Range)
进入 - >
let email = result["email"] as? String