0
votes

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?

1
Sorry to ask a trivial question, but are you sure you saved after doing your updates?ghostatron
yes, sure also, i fetch entity right after i saved context - and it has all correct groups but if i fetch it at another VC - they are goneAndrew
as soon as i add a constraint for Group - model A losts it's set of Groups if i create every time new entity for Group - it works fineAndrew

1 Answers

0
votes

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