views:

125

answers:

1

I've got two entities, one named exercise and the other named workout. I would like to store several different exercises in each workout object.

What is the correct logic here? Create an array of exercises in each workout?

+1  A: 

You can't create arrays in Core Data. You can simulate them, however, using To-Many Relationships. Add a relationship to your Workout entity called, say, exercises. Then set its Destination to the Exercise entity and check the "To-Many Relationship" checkbox. Note that the exercises will be stored as an NSSet, not an NSArray, so they will not be ordered. If you want them to be in a specific order, I would recommend using the BWOrderedManagedObject subclass.

Steve Harrison