Post

Replies

Boosts

Views

Activity

Reply to SwiftData and 'Circular references'
First I was confused as well, but your own comment @Mcorey and looking at the example code helped me to figure it out. As you’ve said you basically have to omit the @Relationship in one of the entities and replace it with a simple variable in the other one. Example Code Main Entity: @Model final public class MainItem { var title: String @Relationship(inverse: \ChildItem.item) var childs: [ChildItem]? } Child Entity: @Model final public class ChildItem { var timestamp: Date // Add inverse as a simple variable var item: ChildItem? }
Topic: App & System Services SubTopic: iCloud Tags:
Jun ’23
Reply to SwiftData and 'Circular references'
First I was confused as well, but your own comment @Mcorey and looking at the example code helped me to figure it out. As you’ve said you basically have to omit the @Relationship in one of the entities and replace it with a simple variable in the other one. Example Code Main Entity: @Model final public class MainItem { var title: String @Relationship(inverse: \ChildItem.item) var childs: [ChildItem]? } Child Entity: @Model final public class ChildItem { var timestamp: Date // Add inverse as a simple variable var item: ChildItem? }
Topic: App & System Services SubTopic: iCloud Tags:
Replies
Boosts
Views
Activity
Jun ’23