ios - FBSDKGraphRequest : result - Value of optional type 'Any?' not unwrapped; did you mean to use '!' or '?' ?

标签 ios swift facebook-graph-api

原始语法:

[

错误是

Value of optional type 'Any?' not unwrapped; did you mean to use '!' or '?'? on result variable

FBSDKGraphRequest(graphPath: "me", parameters: parameter).start { (connection, result, error) in
        if error != nil {
            print(error)
            return
        }
        if let email = result["email"] as? String {
            print(email)
        }
    }

最佳答案

如果 result 应该是一个字典,您必须选择向下转换并将 Any? 解包为预期的类型:

if let item = result as? [String:Any],
   let email = item["email"] as? String {
        print(email)
}

关于ios - FBSDKGraphRequest : result - Value of optional type 'Any?' not unwrapped; did you mean to use '!' or '?' ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47413266/

相关文章:

ios - 手机进入飞行模式时计时器停止,离开 AM 后不会重新启动

swift - 我可以将按钮放入单独的 View 中吗?

Facebook 'Friends.getAppUsers' 使用图形 API

javascript - 如何解决 Facebook 使用移动网络共享时出现的 "API Error code 4202"错误

iphone - 多个类 iOS 中的一个字符串

android - 一种将最小化的 flutter 应用程序带到前台的方法

ios - iPhone:是否可以在点击 UITextField 时隐藏键盘?

ios - setEditing 为 ON 时如何显示 UITableViewCellAccessoryCheckmark?

ios - 如何通过以编程方式创建 UIImage 来更改 UITabBar 顶部边框的颜色?

facebook - 使用公共(public) API 获取 Facebook 视频的观看次数