请帮我从响应中获取值
{
"BU": {
"name": "Bulawayo",
"names": "Bulawayo"
},
"HA": {
"name": "Harare",
"names": "Harare"
}
}
我想要键名的值。我的代码在下面
let response = responseObject as! Dictionary<String,AnyObject>
let stateNames = response.values as! Dictionary<String,AnyObject>
遇到这个问题:
cannot cast from lazyMapCollection<Dictionary<String,Anyobject>,String> in swift
最佳答案
您可以获得“BU”的值作为response.valueForKey("BU").valueForKey("name")
,它将为您提供值“Bulawayo”。
关于Swift 从字典中获取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38519402/