【问题标题】:Cannot convert value of type 'GraphRequestResult<GraphRequest>' to type '[Any]' in coercion无法强制将“GraphRequestResult<GraphRequest>”类型的值转换为“[Any]”类型
【发布时间】:2016-09-27 07:33:44
【问题描述】:

我正在使用新的 facebook 图表请求:

let parameters = ["fields": "id, name, gender"]
                let nextrequest: GraphRequest = GraphRequest(graphPath: "me", parameters: parameters, accessToken: AccessToken.current, httpMethod: .GET)

                nextrequest.start({ (response: HTTPURLResponse?, result: GraphRequestResult<GraphRequest>) in
             //   }) { (connection: GraphRequestConnection! , result: AnyObject!, error: NSError!) -> Void in

                    print(result as [Any])

})

我很难解析它我得到这个错误:

无法将类型“GraphRequestResult”的值强制转换为类型“[Any]”

success(FacebookCore.GraphResponse(rawResponse: Optional({
    gender = male;
    id = 1128614937219535;
    name = "Rayan Slim";
})))

【问题讨论】:

    标签: ios swift facebook facebook-graph-api


    【解决方案1】:

    检查GraphRequestResult 的签名,在您的情况下是(connection: GraphRequestConnection! , result: AnyObject!, error: NSError!),也许Swift 转换正在创建(connection: GraphRequestConnection! , result: AnyObject?, error: Error?)。即NSError -> Error 它是Optional

    【讨论】:

      猜你喜欢
      • 2021-03-08
      • 1970-01-01
      • 2019-11-28
      • 2017-08-25
      • 1970-01-01
      • 1970-01-01
      • 2021-06-18
      • 2021-10-15
      • 1970-01-01
      相关资源
      最近更新 更多