Hi Edson,

Thanks for the response!

Let me think. If I understand you correctly, you want to have categories and tasks (Todos) in them. If that's true, then there two ways to go:

1) Simply store a simple `categoryList` property inside of `TodoListViewModel` and pass it initializing `TodoListView` with it: `TodoListView(viewModel: TodoListViewModel(categoryList: categoryList))`. And do the same for `NewTodoView`.

2) Store a property with the `Binding` wrapper: `@Binding var categoryList: Category?` and pass it as `$categoryList`. This approach is good if you're planning to change this property without reinitializing `TodoListView`. In this case, `TodoListView` will be updated every time you update `categoryList` in `CategoryListView`.

Also, there is a way to store an array of tasks in the `Category` entity, but it might be not memory efficient. In this case, it's better to not hide the Core Data layer and use the Core Data features that allows you to have one-to-many relationship inside your objects with no significant impact on memory. It's a different approach and it's definitely a way to go.

Anyway, in most cases, the 1st approach works good enough.

Let me know, if I answered your question.

Lifelong learner, iOS Developer striving for self improvement

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store