Post

Replies

Boosts

Views

Activity

Comment on How do you create an inverse relationship to the same model in SwiftData
Thanks! I have parent, children and spouse relationships. I was able to add the inverse between parent and children but the trick was spouse, i.e. var spouses: [Person}?. You can't add an inverse to the same property, i.e. @Relationship(inverse: \Person.spouses) because it displays an error saying it is a circular reference but adding another private var did the trick.
Aug ’23