Post

Replies

Boosts

Views

Activity

OutlineGroup and hierarchical List with Core Data
Given a NSManagedObject like below: 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. 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: Key path value type 'Set<Folder>' cannot be converted to contextual type 'FetchedResults<Folder>?' Any idea? As a bonus, the children should also be ordered by the position (because it's a Set, it's unordered)…
7
0
2.6k
Jul ’20