anyone know how to use the new swift concurrency model (ie. await context.perform and context.perform) core data willSave()?
for example. how would I ensure this is thread safe? changing self.managedObjectContext!.performAndWait
to await self.managedObjectContext!.perform
means I have to change willSave()
to async which then means it never gets called because its not overriding the correct method anymore.
override public func willSave() {
self.managedObjectContext!.performAndWait {
if self.modifiedDate == nil || Date().timeIntervalSince(self.modifiedDate!) >= 1 {
self.modifiedDate = Date()
}
}
super.willSave()
}