4

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.

Community
  • 1
  • 1
LShi
  • 1,500
  • 16
  • 29
  • I am convinced that setting propagatesDeletesAtEndOfEvent flag to false and performing operations on the context breaks some underlying assumptions of the library, I cannot get it to work with any relationship in the model. – lkraider Jan 29 '18 at 00:39
  • 1
    Another question that tries to explain what it does: https://stackoverflow.com/questions/3022200/what-does-setpropagatesdeletesatendofevent-actually-do – lkraider Jan 29 '18 at 00:52

0 Answers0