init(_:id:children:selection:rowContent:)
Creates a hierarchical list that identifies its rows based on a key path to the identifier of the underlying data and allowing users to have exactly one row always selected.
Declaration
@MainActor @preconcurrency init<Data, ID, RowContent>(_ data: Binding<Data>, id: KeyPath<Data.Element, ID>, children: WritableKeyPath<Data.Element, Data?>, selection: Binding<SelectionValue>, @ViewBuilder rowContent: @escaping (Binding<Data.Element>) -> RowContent) where Content == OutlineGroup<Binding<Data>, ID, RowContent, RowContent, DisclosureGroup<RowContent, OutlineSubgroupChildren>>, Data : MutableCollection, Data : RandomAccessCollection, ID : Hashable, RowContent : ViewParameters
- data:
The data for populating the list.
- id:
The key path to the data model’s identifier.
- children:
A key path to a property whose non-
nilvalue gives the children ofdata. A non-nilbut empty value denotes a node capable of having children that is currently childless, such as an empty directory in a file system. On the other hand, if the property at the key path isnil, thendatais treated as a leaf node in the tree, like a regular file in a file system. - selection:
A binding to a non optional selected value.
- rowContent:
A view builder that creates the view for a single row of the list.