in your data structure you don't have a hierarchy of parent/children, you only have a flat
array of MapLayerGroup each element containing an array of LayerGroup. So I guess the compiler
cannot make sense of the non tree-structured data. Try a simple list in this case:
List(mapLayerGroups, id: \.id) { layer in
Text(layer.Name)
}
If your intention was to have a tree structure hierachy, then you should have something like this:
struct MapLayerGroup: Hashable, Identifiable {
var id = UUID()
var children: [MapLayerGroup]? = nil // <---
var CanBeDeleted: Bool
var ListOrder: Int
var Mutual: Bool
var Name: String
var ProjectId: Int
var ProjectLayerGroupId: Int
var Xaml: String
var LayerGroups: [LayerGroup]?
}
...
List(mapLayerGroups, children: \.children) { layer in
Text(layer.Name)
}
See also the Apple doc (halfway down the page) at:
Apple Documentation
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: