請幫我從響應斯威夫特GET值從字典
{
"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
感謝烏拉圭回合答覆.. @Bhuatik –
@Bhuatik響應是從服務器,所以我不能指定密鑰名稱 –
@ ThripthiHaridas請檢查我的答案。 –