将记录添加到核心数据

时间:2019-01-08 21:04:54

标签: swift core-data

我想向核心数据添加记录,但出现错误“线程1:信号SIGABRT”

帮我

let appDel:AppDelegate = UIApplication.shared.delegate as! AppDelegate
let context = appDel.persistentContainer.viewContext
let conchym = NSEntityDescription.insertNewObject(forEntityName: "Muoigiay", into: context)
conchym.setValue("date", forKey: "time10")
conchym.setValue("\(diemdung)", forKey: "dung10")
conchym.setValue("\(diemsai)", forKey: "sai10")
// save to data
do {
   try context.save()
} catch {
   print("Failed saving")
}

0 个答案:

没有答案