数据模型
class dataImage {
var userId: String
var value: Double
var photo: UIImage?
var croppedPhoto: UIImage?
init(userId:String, value: Double, photo: UIImage?, croppedPhoto: UIImage?){
self.userId = userId
self.value = value
self.photo = photo
self.photo = croppedPhoto
}
}
视图控制器
var photos = [DKAsset]() //image source
var datas = [dataImage]()
var counter = 0
for asset in photos{
asset.fetchOriginalImageWithCompleteBlock({ image, info in // move image from photos to datas
let images = image
let data1 = dataImage(userId: "img\(counter+1)", value: 1.0, photo: images, croppedPhoto: images)
self.datas += [data1]
counter++
})
}
从这段代码中,假设我有5个数据:
- dataImage(userId: "img1", value: 1.0, photo: images, croppedPhoto:
images)
- dataImage(userId: "img2", value: 1.0, photo: images, croppedPhoto:
images)
- dataImage(userId: "img3", value: 1.0, photo: images, **croppedPhoto:
images**)
- dataImage(userId: "img4", value: 1.0, photo: images, croppedPhoto:
images)
- dataImage(userId: "img5", value: 1.0, photo: images, croppedPhoto:
images)
如何更改/更新img3的croppedImage值?