Generic Structure

ForEach

A structure that computes views on demand from an underlying collection of of identified data.

Declaration

@frozen struct ForEach<Data, Content> where Data : RandomAccessCollection, Content : View, Data.Element : Identifiable

Topics

Type Aliases

typealias ForEach.Modified

The type resulting from applying a view modifier T.

Initializers

init(Data, content: (Data.Element.IdentifiedValue) -> Content)

Creates an instance that uniquely identifies views across updates based on the identity of the underlying data element.

Instance Properties

var content: (Data.Element.IdentifiedValue) -> Content

A function that can be used to generate content on demand given underlying data.

var data: Data

The collection of underlying identified data.

Instance Methods

func modifier<T>(T) -> _ModifiedContent<ForEach<Data, Content>, T>

Returns a new view representing self with modifier applied to it.

func onReceive<P>(P, perform: (P.Output) -> Void) -> SubscriptionView<P, ForEach<Data, Content>>

Adds an action to perform when the given publisher emits an event.

Relationships

See Also

Lists and Scroll Views

struct List

A container that presents rows of data arranged in a single column.

Beta
protocol DynamicViewContent

A type of view that generates views from an underlying collection of data.

Beta
protocol Identifiable

A type that you can compare for identity equality.

Beta
struct ScrollView

A scroll view.

Beta

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software