2
내 coreData에 28 개의 항목이있는 배열을 저장하고 싶습니다. 이 일을 할 수있는 방법이 있습니까? 이 코드로 시도했지만이 코드는 값을 다시 쓰는 것만 같습니다.Swift Array in CoreData
let appDelegate =
UIApplication.shared.delegate as! AppDelegate
let managedContext = appDelegate.persistentContainer.viewContext
let entity = NSEntityDescription.entity(forEntityName: "PillTook",
in:managedContext)
let value = NSManagedObject(entity: entity!,
insertInto: managedContext)
for var index in 0...27 {
value.setValue(false, forKey: "took")
do {
try managedContext.save()
pillTook.append(value)
} catch let error as NSError {
print("Could not save \(error), \(error.userInfo)")
}
}
감사합니다. :) –