One Logo Pool Ball
SwiftUI · IOS API REFERENCE

TableColumnForEach

struct · iOS 17.4+ · SDK 27.1

nonisolated struct TableColumnForEach<Data, ID, RowValue, Sort, Content> where Data : RandomAccessCollection, ID : Hashable, RowValue == Content.TableRowValue, Sort == Content.TableColumnSortComparator, Content : TableColumnContent

A structure that computes columns on demand from an underlying collection of identified data. Use `TableColumnForEach` to create columns based on a <doc://com.apple.documentation/documentation/Swift/RandomAccessCollection> of some data type. Either the collection's elements must conform to <doc://com.apple.documentation/documentation/Swift/Identifiable> or you need to provide an `id` parameter to the `TableColumnForEach` initializer. The following example shows the interface for an `AudioSampleTrack`, which h as a collection of `AudioSample` across a dynamic number of `AudioChannel`s. The `Table` is created for displaying rows for each sample. It has one static column for the sample's timestamp and uses a `TableColumnForEach` instance to produce a column for each of the audio channels in the track. struct AudioChannel: Identifiable { let name: String let id: UUID } struct AudioSample: Identifiable { let id: UUID let timestamp: TimeInterval func level(channel: AudioChannel.ID) -> Double } @Observable class AudioSampleTrack { let channels: [AudioChannel] var samples: some RandomAccessCollection<AudioSample> { get } } struct ContentView: View { var track: AudioSampleTrack var body: some View { Table(track.samples) { TableColumn("Timestamp (ms)") { sample in Text(sample.timestamp, format: .number.scale(1000)) .monospacedDigit() } TableColumnForEach(track.channels) { channel in TableColumn(channel.name) { sample in Text(sample.level(channel: channel.id), format: .number.precision(.fractionLength(2)) ) .monospacedDigit() } .width(ideal: 70) .alignment(.numeric) } } } }

Members (0)

This type has no directly callable members in this snapshot. See the framework’s skipped declarations for unsupported APIs.

Skipped declarations

5 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

TableColumnForEach.data

This declaration needs Swift generic type arguments. (no canonical witness for Data)

TableColumnForEach.content

This declaration needs Swift generic type arguments. (no canonical witness for Data.Element)

TableColumnForEach.init(_:content:)

This declaration needs Swift generic type arguments. (no canonical witness for Data)

TableColumnForEach.init(_:id:content:)

This declaration needs Swift generic type arguments. (no canonical witness for Data)

TableColumnForEach.init(_:content:)

This declaration needs Swift generic type arguments. (no canonical witness for Content)

All SwiftUI types →