Take the 2-minute tour ×

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?

share|improve this question
Look into stackoverflow.com/questions/764125/… –  coverback Aug 1 '12 at 5: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 1 '12 at 7:08
add comment

marked as duplicate by casperOne Aug 2 '12 at 12:51


2 Answers

up vote 1 down vote accepted

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

share|improve this answer
If you found your answer and are satisfied with it, then you should accept it yourself. –  coverback Aug 1 '12 at 5:25
@coverback Says I have to wait 2 days :/ –  random Aug 1 '12 at 7:06
add comment

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

share|improve this answer
What would be the worst case scenario if a set of entities didn't have an inverse relationship set? –  random Aug 1 '12 at 5: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 1 '12 at 6: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 1 '12 at 6:59
add comment
