Setting relationship in model initializer does not update other side of relationship

Originator:darren.mo
Number:rdar://FB13448008 Date Originated:2023-12-05
Status:Open Resolved:
Product:SwiftData Product Version:iOS 17.2 Seed 3 (21C5046c)
Classification:Incorrect/Unexpected Behavior Reproducible:Always
 
I have attached a sample project demonstrating a bidirectional relationship. The `Track` model has a `[TrackToPlaylistRelationship]` property. The `TrackToPlaylistRelationship` model has a `Track` property. The `TrackToPlaylistRelationship` model sets its `Track` property during initialization. Unexpectedly, the initializer does not update the other side of the relationship.

I have annotated `TrackToPlaylistRelationship.swift` and `ContentView.swift` with comments that may be helpful for understanding and investigating this issue.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!