【发布时间】:2017-06-02 06:04:43
【问题描述】:
这是我的代码:
let res = try JSONSerialization.jsonObject(with: data!, options:.mutableContainers) as! [[String:Any]]
数据是Response.data的结果。
它在模拟器中运行良好,但在 iphone6 中控制台输出
Could not cast value of type ‘__NSDictionaryM’ to ‘NSArray’
json数据格式是这样的
[{"":""},{"":""},{"":""}]
jsondata表单服务器适用于android、ios模拟器。但是当涉及到我的 iPhone 设备时,代码失败了。 响应json数据的结果只是{},它是空的,但是在Xcode模拟器上它运行良好。
谁能告诉我为什么?
【问题讨论】:
-
如果不是数组,试试这个:让 res = 试试 JSONSerialization.jsonObject(with: data!, options:.mutableContainers) as! [字符串:任何]
标签: ios iphone json swift xcode