【问题标题】:i am trying to parse json data in swift 1.2 here is the code我正在尝试在 swift 1.2 中解析 json 数据,这是代码
【发布时间】:2016-03-04 20:40:52
【问题描述】:
let jsonResult = NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.MutableContainers, error: nil) as! NSArray

我收到错误:

无法将“__NSDictionaryM”(0x10322f8a8) 类型的值转换为“NSArray”(0x10322f470)。## 标题##

【问题讨论】:

标签: swift


【解决方案1】:

错误说明了一切,该函数返回一个 NSDictionary 数据类型,而您试图将其强制输入为 NSArray,这两种类型之间没有自动转换。 查看link 了解如何将键转换为数组,然后您可以使用数组中的键来访问字典值。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-16
    • 1970-01-01
    • 1970-01-01
    • 2018-05-15
    • 1970-01-01
    • 2012-12-25
    相关资源
    最近更新 更多