oc

2018-09-10  本文已影响0人  970517
  1. let s = StudenModel()

     let deal = DealData()
     
     var dictArray : [[String:String]] = []
     
     for _ in 0..<5 {
         let dict = ["name":"Lily","age":"23","gender":"nv"]
         
         dictArray.append(dict)
         
     }
     
     let arrayModel = deal.returnModelArray(arrayDict: dictArray)
     
     for model in arrayModel {
         print(model.name)
         print(model.age)
         print(model.gender)
     }
     print(arrayModel)
     
     2.
    

protocol DealDataProticol {

func returnModelArray(arrayDict : [[String:String]]) -> [StudenModel]

}

  1. func returnModelArray(arrayDict: [[String : String]]) -> [StudenModel] {
    var array : [StudenModel] = []
    for dict in arrayDict {
    let stdent = StudenModel()
    stdent.name = dict["name"] ?? ""
    stdent.age = dict["age"]!
    stdent.gender = dict["gender"]!
        array.append(stdent)
    }
    return array
}
上一篇下一篇

猜你喜欢

热点阅读