swift杂记

1.JSONExport工具(model文件生成工具) https://blog.csdn.net/u010596262/article/details/78025780?locationNum=9&fps=1

2.SwiftyJSON 模型转换 参考https://www.jianshu.com/p/a3000bf95650


static func modelArrayWithJsonArray(jsonArray:[JSON]) -> [QuationCoinExchangeInfoListModel] {
        
        var modelArray = [QuationCoinExchangeInfoListModel]()
        for json in jsonArray {
            modelArray.append(QuationCoinExchangeInfoListModel(json))
        }
        
        return modelArray
    }

1、原始的手动解析
        market_list = QuationCoinExchangeInfoListModel.modelArrayWithJsonArray(jsonArray: json["market_list"].arrayValue)
        2、简化
        market_list = json["market_list"].arrayValue.map({ (json) ->QuationCoinExchangeInfoListModel in
            
            return QuationCoinExchangeInfoListModel(json)
        })
        3、最简化,推荐使用
        /// !!!!!
        market_list = json["market_list"].arrayValue.map { QuationCoinExchangeInfoListModel($0) }

你可能感兴趣的:(swift杂记)