从'(键:字符串,值:AnyObject)'转换不相关的类型' [String:Any]'总是

时间:2018-02-18 14:33:58

标签: json swift

我正在尝试解析JSON响应并使用swift在tableView中显示它。

以下是代码:

Cast from '(key: String, value: AnyObject)' to unrelated type '[String : Any]' always fails

我收到错误:

1 0 1 0 1 1 0 0 1 0 1 1
          x potential static point
    <----- would extend to
           -----> would extend to

left cost at x: 3 - 2 = 1
right cost at x: 3 - 1 = 2

有什么问题?

数据如下所示:https://api.tfl.gov.uk/journey/journeyresults/1000266/to/1000013

1 个答案:

答案 0 :(得分:1)

fetchedData是一本字典。当您枚举字典时,会得到(key: Key, value: Value)的元组。看起来你希望fetchedData是一个数组,或者你的意思是

for eachFetchedJourney in fetchedData.values

如果您要展示JSON的样子,我们可以帮助您。