Swift:无法将'__NSCFArray'类型的值转换为'NSDictionary'

Ale*_*tev 3 dictionary ios swift swift2

我有来自网站的JSON数据.我制作了主词典,我可以解析除一个子词典之外的所有数据.我收到错误"Swift:无法将类型'__NSCFArray'的值转换为'NSDictionary'"

我的数据示例.我无法解析"天气",但我可以解析所有其他词典"wind".

   ["name": Mountain View, "id": 5375480, "weather": (
        {
        description = "sky is clear";
        icon = 01n;
        id = 800;
        main = Clear;
    }
), "base": cmc stations, "wind": {
    deg = "129.502";
    speed = "1.41";
Run Code Online (Sandbox Code Playgroud)

代码片段

 let windDictionary = mainDictionary["wind"] as! [String : AnyObject
 let speed = windDictionary["speed"] as! Double
 print(speed)
 let weather = mainDictionary["weather"] as! [String : AnyObject]
 print(weather)
Run Code Online (Sandbox Code Playgroud)

EI *_*2.0 16

代表你的评论...我想说windDictionary是字典...

Dictionary denotes in JSON with {} and 
Array denotes with [] // In printed response you may have array with ()
Run Code Online (Sandbox Code Playgroud)

所以,你的天气部分是字典数组...你必须解析它

 let weather = mainDictionary["weather"] as! [[String : AnyObject]]  // although please not use force unwrap .. either use `if let` or `guard` statement
Run Code Online (Sandbox Code Playgroud)