【发布时间】:2015-01-13 08:45:53
【问题描述】:
我正在使用SwiftyJSON 解析JSON array,但无法弄清楚为什么在解析数组以填充Dictionary 时无法使用这些值。
var dictionary = [String: String]()
for (index: String, subJson: JSON) in json[myArray] {
let name = subJson["name"].string
let value = subJson["value"].string
gameOwned += [name: value]
}
我在这一行收到此错误:
gameOwned += [name: value]
我将它添加到空字典中是错误的吗?我已经测试了name 和value 的值,它们 println 没有问题。
【问题讨论】:
-
试试
dictionary[name] = value -
试试
gameOwned! += [name: value]
标签: json dictionary swift