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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t create arrays in Core Data. You can simulate them, however, using To-Many Relationships. Add a relationship to your
Workoutentity called, say,exercises. Then set its Destination to theExerciseentity and check the “To-Many Relationship” checkbox. Note that the exercises will be stored as anNSSet, not anNSArray, so they will not be ordered. If you want them to be in a specific order, I would recommend using theBWOrderedManagedObjectsubclass.