Hi guys, I have an issue with many-to-many relationships in SwiftData. Even though the order of actions is correct; I fist create the objects with their non optional array initialized empty in their own init-method’s parameter and then insert the models in the model context. For example:
- Create model A
- Insert model A
- Create model B
- Insert model B
And then I try to establish their relationships by modifying model A’s array, however model B’s array doesn’t update correctly and gives wrong results. How can I fix this?
If needed, I can for sure provide some code but since the code of these actions is all over the project, I thought it would be easier to first try and explain it simply like this. Thanks for any expertise or opinions! Have a great day!