Contents

init(_:content:)

Creates an instance that uniquely identifies and creates map content across updates based on the identity of the underlying data.

Declaration

@MainActor init(_ data: Data, @MapContentBuilder content: @escaping (Data.Element) -> Content) where ID == Data.Element.ID, Data.Element : Identifiable

Parameters

  • data:

    The identified data that the Foreach instance uses to create map content dynamically.

  • content:

    The map content builder that creates map content dynamically.

Discussion

It’s important that the id of a data element doesn’t change unless you replace the data element with a new data element that has a new identity. If the id of a data element changes, the content view generated from that data element loses any current state and animations.

See Also

Creating a collection