I want to set a relationship between two entities and I want it both to have an inverse relationship. However I couldn’t set the inverse relationship in Xcode.
For example, given the following scenario where I have
Movie entity and
Actor entity. A
Movie should casts multiple
Actor, so I want the entity to have a
cast relationship between the
Here’s the graph editor to help you visualize it.
However when I try to set the
cast relationship in the editor, I’m not able to set the inverse relationship since the option is not available to me.
How do I fix this?
Apparently, I have to set the relationship in the Destination entity first to have the option for inverse relationship. In this case, I need to set up a
movies relationship in the
Actor entity first. Like so
Once I go back to the
Movie entity’s `cast` relationship, there should be an option to set the inverse relationship to the
movies relationship that I defined earlier in
Personally, I feel like this is a lot of work. Luckily I discovered that if you set the relationship through the Graph editor, it will do the work for you. All you have to do
CTRL drag to the destination entity. Like so:
Then, rename the relationship to
movies respectively. That’s it.