Database Reference
In-Depth Information
Go back to the Dog entity. You might think you need to add a new attribute of type
Array to hold the walks, but there is no Array type in Core Data. Instead, the way
to do this is to model it as a relationship. Add a new relationship and name it
walks :
Set the destination to Walk . You can think of the destination as the receiving end
of a relationship.
Every relationship begins as a to-one relationship by default, which means you can
only track one walk per dog at the moment. Unless you don't plan on keeping your
dog for very long, you probably want to track more than one walk.
To fix this, with the walks relationship selected, open the Data Model inspector:
Click on the Type dropdown, select To Many and check Ordered . This means one
dog can have many walks and the order of the walks matters, since you'll be
displaying the walks sorted by date.
Select the Walk entity and create an inverse relationship back to Dog . Set the
destination as dog and the inverse as walks .
 
Search WWH ::




Custom Search