TableColumnContent
A type used to represent columns within a table.
Declaration
type TableColumnContent = SwiftOpaque<'TableColumnContent'>;@MainActor @preconcurrency protocol TableColumnContent<TableRowValue, TableColumnSortComparator>Overview
This type provides the body content of the column, as well as the types of the column's row values and the comparator used to sort rows.
You can factor column content out into separate types or properties, or
by creating a custom type conforming to TableColumnContent.
var body: some View {
Table(people, selection: $selectedPeople, sortOrder: $sortOrder) {
nameColumns
TableColumn("Location", value: \.location) {
LocationView($0.location)
}
}
}
@TableColumnBuilder<Person, KeyPathComparator<Person>>
private var nameColumns: some TableColumnContent<
Person, KeyPathComparator<Person>
> {
TableColumn("First Name", value: \.firstName) {
PrimaryColumnView(person: $0)
}
TableColumn("Last Name", value: \.lastName)
TableColumn("Nickname", value: \.nickname)
}The above example factors three table columns into a separate computed
property that has an opaque type. The property's primary associated
type TableRowValue is a Person and its associated type
TableColumnSortComparator is a key comparator for the Person type.
A type conforming to this protocol inherits @preconcurrency @MainActor
isolation from the protocol if the conformance is included in the type's
base declaration:
struct MyCustomType: Transition {
// `@preconcurrency @MainActor` isolation by default
}Isolation to the main actor is the default, but it's not required. Declare the conformance in an extension to opt out of main actor isolation:
extension MyCustomType: Transition {
// `nonisolated` by default
}From Apple’s SwiftUI documentation. Code samples there are Swift.
See also
More in Lists and tables.
- ListItemTintA tint effect configuration that you can apply to content in a list.
- ListSectionSpacingThe spacing options between two adjacent sections in a list.
- PaletteSelectionEffectThe selection effect to apply to a palette item.
- SectionCollectionAn opaque collection representing the sections of view.
- SensoryFeedbackSelectionFeedbackFeedback that can be played in response to a specific UI element's values changing.