I am having troubles implementing Relationships into my project. My project consists of two Entities: Item and List
Item has a one to one relationship with List and is non-optional (i.e an Item has to be related to a List)
List has a one to many relationship (i.e the list can consist of multiple Items)
My problems arise when I try to implement the assignment of the relationship. My main issue is that I don't know where two implement the assignment function. I have tried a few things but have either had problems with getting nil-values (most likely related to the ViewModels). I have decide not to post all my attempts and the corresponding errors in order to keep the post more readable and structured(instead I was thinking of posting them afterwards in response to an answer).
For context I made a GitHub repository: https://github.com/Standwerth/Standwerth-SwiftUI-Core-Data-Relationships-with-MVVM
I am using a CoreDataManager file and ViewModels to communicate the logic.
EDIT: After troubleshooting a for a really long time I believe I found what caused the problem. The problem was most likely that I by mistake checked List to be the Parent entity of Item.
I will let the post stay up so that if anyone runs in to the same problem they can double check to make sure they didn't make the same mistake as me. If moderators feel the need to delete the question feel free to.