I currently have two entities, a category entity and an item entity, where Category:Item is 1:m.
I have applied the “No Action” rule to the Category -> Item relationship, and implemented Category.prepareForDeletion to move all items in the category to a special catch-all category prior to deleting the category (the catch-all category is not deletable).
- (void)prepareForDeletion {
Category *misc = [Database theMiscCategory];
[misc addItems:self.items];
[super prepareForDeletion];
}
My question is this: am I missing anything? And if not, how do I turn off the XCode warning about “No Action” being an advanced feature?
FTR, I’m not using nullify because it is more convenient for other areas of the application to dump stuff in a “misc” category rather than handling items with a null category. I did actually try that originally, but got some unexpected behaviour – if I put the call to super first, the relationships were nullified before I could collect the set of items to change, if I put it after then the relationships to the new category got nullified. I suppose I could collect them, then call super, then set the new category, but that seems klunky.
So I do think “No Action” is what I want, just want to make sure I’m not missing anything else that I should be managing in prepareForDeletion.
So, between reading & soak time, the answer seems to be very simple: yes, if you have a reason to use “nullify”, then what you need to do is implement prepareForDeletion appropriately to maintain referential integrity.