An array of objects in the main data structure?

I have two entities, one of which is called exercise, and the other named training. I would like to keep several different exercises in each object of training.

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

+3
source share
1 answer

You cannot create arrays in Core Data. You can imitate them, however, using To-Many Relationships. Add a link to your project Workout, and name it exercises. Then set its purpose to the object Exerciseand select the "Interact with many" checkbox. Please note that exercises will be stored as NSSet, and not NSArray, therefore, they will not be ordered. If you want them to be in a specific order, I would recommend using a subclass BWOrderedManagedObject.

+8
source

Source: https://habr.com/ru/post/1743613/


All Articles