Core Data Relationships cause save error after delete

后端 未结 8 1716
粉色の甜心
粉色の甜心 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:26

    I can't mark this solved, because I didn't really solve it, but I do have a working work-around. In the .m for each of my managedObjects I added a method that looks like:

    -(void) deleteFromManangedObjectContext{ 
       self.outfit = nil; 
       self.article = nil; 
       [[self managedObjectContext] deleteObject:self]; 
    } 
    

    So you can see, first I manually nil out the relationships, and then I have the object delete itself. In other objects, instead of nil-ing, my delete method is called on some of the objects relationships, to get a cascade.

    I'm still interested in the "right" answer. But this is the best solution I have, and it does allow for some fine-grained control over how my relationships are deleted.

提交回复
热议问题