Core Data relationship question

I'm looking to understand the connection between relationships in core data. What I'm trying to do is store two entities 'Workout' and 'Exercise' and allow multiple 'Exercises' to one 'Workout'. Im'm coming from a MYSQL background so it's a little fuzzy when it comes to the relation.


How would I be able to keep the reference to the workout object, use some variable to store the objectID and then use it to update the exercise entity?


Thanks

The relationship mechanics deal with everything for you if the entities are in the same store, so you only ever deal with NSManagedObject instances. In use, relationships just pretty much work like the "normal" properties of the managed objects, and the framework hides the objectID related implementation details from you.


If you define an 'exercises' relationship on Workout that is to-many to Exercise, the defined accessor to add an exercise to the relationship should be something like addExercisesObject. So


Workout yourWorkout;

Exercise theNewExercise;

[yourWorkout addExercisesObject: theNewExercise];


DIsclaimer: Typing code into the browser that I normally rely on auto-complete to finish the names for.

Core Data relationship question
 
 
Q