Relationships

One of the benefits of using Core Data is that entities can be related to one another in a way that allows you to describe complex models. Relationships between entities are represented by references between objects. There are two kinds of relationships: to-one and to-many.

When an entity has a to-one relationship, each instance of that entity has a reference to a single instance of another entity.

When an entity has a to-many relationship, each instance of that entity has a reference to a Set. This set contains the instances of the entity that it has a relationship with. To see this in action, you are going to add a new entity to the model file.

Open the Photorama application. In Photorama.xcdatamodeld, add an ...

Get iOS Programming: The Big Nerd Ranch Guide, 7th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.