错误滴
let jsonData = try! NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers)
print("_______________________________________________________________________________________________________________")
print(jsonData)
let dictionary = jsonData as? NSDictionary
let findModel = FindModel()
if (dictionary!.isKindOfClass(NSDictionary.self) == true ){
findModel.setValuesForKeysWithDictionary((dictionary as! Dictionary<String,AnyObject>))
let dataDictionary = findModel.data as! Dictionary<String,AnyObject>
let dataModel = FindDataModel()
dataModel.setValuesForKeysWithDictionary(dataDictionary)
let baseInfoDictionary = dataModel.baseInfo as! Dictionary<String,AnyObject>
let baseInfoModel = FDataBaseInfoModel()
baseInfoModel.setValuesForKeysWithDictionary(baseInfoDictionary)
dataModel.baseInfo = baseInfoModel
findModel.data = dataModel
}
return findModel
从上往下 ,是不行滴。
必须 ,自下而上。
let jsonData = try! NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers)
let dicionary = jsonData as! Dictionary<String,AnyObject>
let findModel = FindModel()
findModel.setValuesForKeysWithDictionary(dicionary)
let dataModel = FindDataModel()
let dataDictionary = dicionary["data"] as! Dictionary<String,AnyObject>
dataModel.setValuesForKeysWithDictionary(dataDictionary)
let baseInfoModel = FDataBaseInfoModel()
let baseInfoDictionary = dataDictionary["baseInfo"] as! Dictionary<String,AnyObject>
baseInfoModel.setValuesForKeysWithDictionary(baseInfoDictionary)
dataModel.baseInfo = baseInfoModel
findModel.data = dataModel
print("***********************************************************************************************")
print(findModel)
return findModel