I have a NSManagedObjectContext
instance that have non-nil value in undoManager
property, and I have a method to increment integer value of all managed objects like this:
func incrementAllOrderProperty() {
let fetchRequest: NSFetchRequest<Entity> = Entity.fetchRequest()
fetchRequest.sortDescriptor = mySortDescriptors
let entities = try! managedObjectContext.fetch()
for entity in entities {
entity.order += 1
}
}
My question is that the context makes sure reducing each process in the loop makes into one undo operation? or dividing processes to multiple undo operations? and is there a way to set an explicit undo context to the managedObjectContext?