您好我需要覆盖CoreData
上的值(如果已经存在)。例如,如果已经在CoreData
我有乔希我需要删除今明保存新的乔希覆盖核心数据值
func save(value:String, forkey:String) {
let context = getContext()
let entity = NSEntityDescription.entity(forEntityName: "Lastname", in: context)
let add = NSManagedObject(entity: entity!, insertInto: context)
add.setValue(value, forKey: forkey)
do {
try context.save()
print("save -> \(value)")
} catch {
print("err \(error)")
}
}
看看这个教程https://www.raywenderlich.com/145809/getting-started-core-data-tutorial。所有基本的方法都在这里很好的描述和实施。 – Oleshko
你的意思是如果在核心数据中发现更新值,你的意思是? – Aditya
@Adi是的,对不起;)检查 - >如果发现删除并保存 - >如果不仅保存 – k0le