问题
I have a pair of Core Data Entities of One-to-Many relationship.
Department <-(optional) (delete rule: Cascade) (optional)->> Item
Item <-(optional) (delete rule: Nullify) (optional)->> Department
Item
is a tree node-like entity, which also has a relationship to itself. The tree can grow quite large (more than 10 thousands nodes in a root branch).
There are a parent background NSManagedObjectContext
and a main-queue one as the child.
In the hope of making deletion of Items
feel faster, I set the main-queue MOC's propagatesDeletesAtEndOfEvent to false
. (The change will be saved when the app Resigns Active. ) Unfortunately there will be error messages when the main-queue MOC is saved:
validation recovery attempt FAILED with Error Domain=NSCocoaErrorDomain Code=1600 ...
If propagatesDeletesAtEndOfEvent
is the default true
, there's no error.
My deletion code looks like this, nothing special:
department.removeFromItems(items as NSSet) // Optional. Also tried without this line.
for i in items {
self.managedObjectContext!.delete(i)
}
I see very few talks about the usage of propagatesDeletesAtEndOfEvent
. Any examples or explainations of the error will be appreciated.
Here is a related question. But it has nothing to do with the propagatesDeletesAtEndOfEvent
property.
Another question about deleting large number of objects.
来源:https://stackoverflow.com/questions/42675933/nsmanagedobjectcontexts-propagatesdeletesatendofevent-set-to-false-causes-error