我需要改变"点火"在指定id的coreData中,但我不能使用谓词。
func saveIgnition(){
let predicate = NSPredicate(format: "objectNo == %@", oDriver.sObjectNo)
let sort = NSSortDescriptor(key:"objectNo", ascending:true)
print(oDriver.sObjectNo)
print("is 0 o 1: ", oDriver.iIgnition)
// we set up our entity by selecting the entity and context that we're targeting
let entity = NSEntityDescription.insertNewObject(forEntityName: "Driver", into: oMain.moc)
let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: "Driver")
fetchRequest.predicate = predicate
fetchRequest.sortDescriptors = [sort]
entity.setValue(self.oDriver.iIgnition, forKey: "ignition")
do {
try oMain.moc.save()
fetchIgn()
} catch {
fatalError("Failure to save context: \(error)")
}
}