0
votes

I'm modeling a relationship in Core Data where an object Foo can have multiple Item's and an Item cannot exist without a Foo.

In the Core Data model, I have object Foo which has an optional to-many relationship named "items" to object Item where the delete rule is to cascade. Each Item has a non-optional inverse relationship back to Foo named "foo" where the count = 1 and the delete rule is set to nullify.

Currently,

foo.items = newItems;

results in the inverse relationship to Foo being nil'd for each of the old items. Is there a way to setup Core Data to preserve the inverse relationship on the old items (so they still point back to foo)?

1
So, you want foo.items to contain all of the old values in items plus all of the new ones in newItems? - Tom Harrington

1 Answers

0
votes

Why would you want to do that? It seems that since you're assigning a new set of Items (who will begin referring to the Foo), the old items should no longer refer to the Foo?