I want to create a one to many relationship. My setup is something like:
I have the Profile Entity, I have the Time entity.
Every profile has a relationship to Time.
How can I define relationships, and add multiple Time entities to a single profile?
I bet it is obvious, but I can't see how to implement.
edit after posting the answer I saw your comment - to define a to-many relationship in the modeller, select the relationship and choose to-many from the options:
To populate the relationship, you can do it two ways. I am assuming your Profile entity has a to-many relationship called times
and the inverse relationship is a to-one relationship called profile
.
profile
on each Time entity as you are creating them. This will automatically populate the inverse relationship (ie add the Time to the times
set of the profile). times
property to this set. Again, the inverse will be automatically populated. There is more information here . Accessor methods to add individual entities to a to-many relationship can be generated from the managed object model editor in Xcode.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.