Given a NSManagedObject like below:
I'd like to use the new OutlineGroup to build an outline view of the folder structure using a FetchRequest.
But this doesn't compile, with the following error:
As a bonus, the children should also be ordered by the position (because it's a Set, it's unordered)…
Code Block public class Folder: NSManagedObject, Identifiable { @NSManaged public var name: String @NSManaged public var position: Int16 @NSManaged public var parentFolder: Folder? @NSManaged public var folders: Set<Folder> }
I'd like to use the new OutlineGroup to build an outline view of the folder structure using a FetchRequest.
Code Block struct FolderView { @FetchRequest(entity: Folder.entity(), sortDescriptors: [NSSortDescriptor(keyPath: \Folder.position, ascending: true)]) var folders: FetchResults<Folder> var body: some View { OutlineGroup(folders, children: \.folders) { folder in Label(folder.name, systemImage: "folder.fill") }
But this doesn't compile, with the following error:
Any idea?Key path value type 'Set<Folder>' cannot be converted to contextual type 'FetchedResults<Folder>?'
As a bonus, the children should also be ordered by the position (because it's a Set, it's unordered)…