类型 'Any?' 没有下标成员

Type 'Any?' has no subscript members

我正在尝试在我的应用程序中登录 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.
    }
}

改变这个

 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
    }

为Swift3.

改变这个-->

let email = result["email"] as? String

进入-->

if let fbemail = (result as AnyObject)["email"]! as? String
{
   print(fbemail)
}