0

Possible Duplicate:
Does every Core Data Relationship have to have an Inverse?

I am following the Core Data tutorial by Ray Wenderlich.

In his example he sets up two entities and creates a one-to-one relationship between them. He then states:

Apple recommends that whenever you create a link from one object to another, you create a link from the other object going back as well.

My question is, if I create EntityA that has a to-many relationship to EntityB, do I need to link back from EntityB to EntityA?

Community
  • 1
  • 1
random
  • 8,568
  • 12
  • 50
  • 85
  • Look into http://stackoverflow.com/questions/764125/does-every-core-data-relationship-have-to-have-an-inverse – coverback Aug 01 '12 at 05:25
  • @coverback I apologize for the duplicate post. I had been searching and searching and could never find a straight forward answer. (and yes, I did google it and a simple google search didn't bring anything up :P). – random Aug 01 '12 at 07:08

2 Answers2

1

Well, I was having a bit of a brain fart but I found my answer.

The answer is YES! You do have to set a link going back (inverse).

Here is what my model looked like before setting the links back:

enter image description here

After setting the links back it looks a bit cleaner:

enter image description here

Here is what the inspector settings look like if anyone else is having the same problem:

enter image description here

random
  • 8,568
  • 12
  • 50
  • 85
1

Yes, for the sake of data integrity all of your relationships should have an inverse relationship.

Michael Frederick
  • 16,664
  • 3
  • 43
  • 58
  • What would be the worst case scenario if a set of entities didn't have an inverse relationship set? – random Aug 01 '12 at 05:35
  • Data loss would be worst case I believe. For example, when inverse relationships aren't set I have seen data loss when doing an auto migration to a newer version of a core data DB. – Michael Frederick Aug 01 '12 at 06:54
  • Of course data loss would the worst case! haha The second part of your answer was that I was looking for. Thank you very much +1 – random Aug 01 '12 at 06:59