Generic Initializer

init(_:id:selection:rowContent:)

Creates a list that identifies its rows based on a key path to the identifier of the underlying data.

Declaration

init<Data, ID, RowContent>(_ data: Data, id: KeyPath<Data.Element, ID>, selection: Binding<SelectionValue?>?, @ViewBuilder rowContent: @escaping (Data.Element) -> RowContent) where Content == ForEach<Data, ID, HStack<RowContent>>, Data : RandomAccessCollection, ID : Hashable, RowContent : View

Parameters

data

The data for populating the list.

id

The key path to the data model’s identifier.

selection

A binding to a selected value.

rowContent

A view builder that creates the view for a single row of the list.

See Also

Creating a List

init(content: () -> Content)

Creates a list with the given content.

init<Data, ID, RowContent>(Data, id: KeyPath<Data.Element, ID>, rowContent: (Data.Element) -> RowContent)

Creates a list that identifies its rows based on a key path to the identifier of the underlying data.

init<Data, ID, RowContent>(Data, id: KeyPath<Data.Element, ID>, selection: Binding<Set<SelectionValue>>?, rowContent: (Data.Element) -> RowContent)

Creates a list that identifies its rows based on a key path to the identifier of the underlying data.

init<RowContent>(Range<Int>, rowContent: (Int) -> RowContent)

Creates a list that computes its views on demand over a constant range.

init<Data, RowContent>(Data, rowContent: (Data.Element) -> RowContent)

Creates a list that computes its rows on demand from an underlying collection of identifiable data.

init<RowContent>(Range<Int>, selection: Binding<Set<SelectionValue>>?, rowContent: (Int) -> RowContent)

Creates a list that computes its views on demand over a constant range.

init<RowContent>(Range<Int>, selection: Binding<SelectionValue?>?, rowContent: (Int) -> RowContent)

Creates a list that computes its views on demand over a constant range.

init<Data, RowContent>(Data, selection: Binding<Set<SelectionValue>>?, rowContent: (Data.Element) -> RowContent)

Creates a list that computes its rows on demand from an underlying collection of identifiable data.

init<Data, RowContent>(Data, selection: Binding<SelectionValue?>?, rowContent: (Data.Element) -> RowContent)

Creates a list that computes its rows on demand from an underlying collection of identifiable data.

init(selection: Binding<Set<SelectionValue>>?, content: () -> Content)

Creates a list with the given content that supports selecting multiple rows.

init(selection: Binding<SelectionValue?>?, content: () -> Content)

Creates a list with the given content that supports selecting a single row.