修改数组中的某个model的值
2019-01-26 本文已影响4人
落夏简叶
- 注意Swift的数组是结构体。用for model in array 修改model的方法行不通
应该直接对数组的值进行操作。参考下面:
func handlePicModel() {
guard let _ = truckPostModel.pics else { return }
for i in 0..<truckPostModel.pics!.count {
truckPostModel.pics![i].smallUrl = truckPostModel.pics![i].url?.getSmallImageString()
truckPostModel.pics![i].bigUrl = truckPostModel.pics![i].url?.getBigImageString()
}
}