这是我的代码:
if let responseDic = response as? Dictionary<String, AnyObject>
{
var temp = Array<Store>.init()
var dataDic = responseDic["data"] as? Dictionary<String, AnyObject>
if dataDic != nil {
for storeList in dataDic!["stores"] as! NSArray {
if let store = storeList as? Dictionary<String, AnyObject>
{
temp.append((Store(dictionary: store)))
}
}
}
我遇到崩溃错误:无法将类型'__NSSingleEntryDictionaryI'(0x10d249f78)的值强制转换为'NSArray'(0x10d24b008)。为此行:for storeList in dataDic!["stores"] as! NSArray
这是我的回复结构:
{
"data": {
"stores": {
"items": [
{...}]
}
}
答案 0 :(得分:0)
您需要转换
for storeList in dataDic!["stores"] as! NSArray
到
if let dic = dataDic!["stores"] as? [String:Any] {}