Andrew
Andrew

Reputation: 573

Core Data Relationship issue

I Have next simple scheme:

Model A groups ----> Model Group

So model A has one to many relationships to model Group Group has an inverse relationship to model A Delete rule - nullify

I have an xml I receive from backed where each model A has an array of Groups

I want to save in Core Data only one entity per Group

So first i check if i have model A entity in Core Data if i don't - i create it if i do - i update it with new info from the backend, including an array of Groups

For each Group i also check if it already exists, and then create if it doesn't Or simple add existing group to model A

And it looks like it's all good - model A has a set of Group entities

But when i fetch the model A entity at another part of the app (another VC) - Group set is empty

And i have no idea why.

Any ideas what is the reason? Or how i can provide uniqueness of one to many relationship at CD?

Upvotes: 0

Views: 28

Answers (1)

Andrew
Andrew

Reputation: 573

looks like correct combo is cascade delete rule + many - to many relationship

Upvotes: 0

Related Questions