我想从CoreData捕获数据,然后将其保存在图像数组中。因此,它在运行时获取所有图像,但在数组中始终是最后一个图像,我需要数组中的所有图像。我的问题在这里是什么?
感谢您的帮助:)
var playImages: [UIImage] = []
let fetchRequest = NSFetchRequest(entityName: "EveryPicture")
do {
let result = try mgdContext.executeFetchRequest(fetchRequest)
if let objects = result as? [EveryPicture] {
for foto in objects {
let image = UIImage(contentsOfFile: foto.everyfoto!)
print("\(image)")
playImages = [image!]
}
}
}catch {
print("Error")
}
print("\(playImages)array")