Post

Replies

Boosts

Views

Activity

Reply to SwiftData Inheritance Query Specialized Model
Thanks a lot for helping Ziqiao, i've made a small iOS App that shows the issue which is available here: https://github.com/fgirardey/SwiftDataInheritance The step to reproduce are: Create a collection named "Work" Create another collection name "Tech" that has "Work" as a parent Kill the app, relaunch and see the crash happening when List is accessing to \children through \.childrenOrNil.
1w
Reply to SwiftData Inheritance Query Specialized Model
Hi Ziqiao, I've tried with iOS 26 Beta 7 and since Beta 8 (landed tonight) on device (because my Xcode is stuck on iOS Beta 6, don't know why) and the problem is solved. I can now query CollectionItem with predicate that contains inherited properties. Now I have only got problems with accesses to the children property in List. When i got the following hierarchy and the SwiftUI view List access to the \Item.children property I got another kind of crash. Category: "Work" (parent: none) Category: "Tech" (parent: "Work") Thread 1: Fatal error: Never access a full future backing data - PersistentIdentifier(id: SwiftData.PersistentIdentifier.ID(backing: SwiftData.PersistentIdentifier.PersistentIdentifierBacking.managedObjectID(0x9872c0007ba42159 <x-coredata://E5407415-7D6A-4920-B910-6D0D39290E5E/CollectionItem/p1>))) with Optional(7639D151-5D48-46AC-AB2A-7F0F50919AC5) But I guess it's a different kind of problem now.
1w
Reply to SwiftData Inheritance Query Specialized Model
Here is the CollectionItem model: @available(iOS 26, *) @Model final class CollectionItem: Item { var name: String var icon: String? init( name: String, icon: String? = nil, parent: CollectionItem? = nil, timestamp: Date = .now ) { self.name = name self.icon = icon super.init(parent: parent) } } Do you really need such a complex solution? I'm not sure, what I want is to mix CollectionItem and LinkItem. Collections can have children, Links cannot. It's like a file system where a directory can have directories or files. So yeah it's a bit complex but this might not be that exotic. There is probably a better way to design this…
1w