Core Data Relationships cause save error after delete

后端 未结 8 1629
粉色の甜心
粉色の甜心 2020-12-29 04:37

This question is probably a long shot. I can\'t figure out the errors I\'m getting on my core data project when I save after I delete an entity.

I have two main enti

相关标签:
8条回答
  • 2020-12-29 05:30

    Do you happen to implement some of the accessor to the relationship yourself? I once had a code like

    -(NSSet*)articles
    {
           re-calculates properties....
           return [self primitiveValueForKey:@"articles"];
    }
    

    in a subclass of NSManagedObject and had a save error. What happened was that, when this object is deleted from the ManagedObjectContext, the CoreData calls the accessor "articles" to deal with the delete propagation. This re-calculation of articles occurred during the delete propagation, which re-surrected the nullified "articles" in my case.

    0 讨论(0)
  • 2020-12-29 05:33

    Check your xcdatamodel file for a Deny delete rule. Click on each relationship until you find it. You'll need to change this rule or adjust how you delete managed objects to anticipate the rule's application to the relationship.

    0 讨论(0)
提交回复
热议问题