Post

Replies

Boosts

Views

Activity

Reply to OutlineGroup and hierarchical List with Core Data
My Solution for this problem is the follow: Element is a NSManagedObject with property children  @FetchRequest(     entity: Element.entity(),     sortDescriptors: []   ) var endpoints: FetchedResults<Element> // use auxiliar function for transform fetch to Array  func data() -> [Endpoint]{     var data : [Endpoint] = []     endpoints.forEach { data.append($0) }     return data   } //in body // List consume data from auxiliar function  List(data(), id: \.self, children: \.wrapperChildren) {item in           Text("\(item.name!)") } //Finally, Create a extension for you object extension Element {         var wrapperChildren: [Element]? {       get { //this validation is important, for dont show arrow expand in List         if self.children?.count == 0 {           return nil         }         return self.children?.allObjects.map{$0 as! Endpoint}       }     } } that code is 100% functionally
Oct ’20