SwiftData Relationships

I like knowing what I'm looking at in my code, so I'd like to know explicitly that the SwiftData variable that is the inverse is "decorated" with the @Relationship macro also, so:

Can I use the @Relationship macro on the inverse class of a relationship if I don't specify it with .inverse ?

IE: From Company @Relationship(deleteRule: .nullify, inverse: \Address.company) var addresses: [Address]?

and set the other as:

From Address @Relationship var company: Company?

Answered by DTS Engineer in 797769022

Can I use the @Relationship macro on the inverse class of a relationship if I don't specify it with .inverse ?

Yes, this works. You can use @Relationship on both sides, but can only specify .inverse on one side.

Can I use the @Relationship macro on the inverse class of a relationship if I don't specify it with .inverse ?

Yes, this works. You can use @Relationship on both sides, but can only specify .inverse on one side.

SwiftData Relationships
 
 
Q