Contents

init(_:id:content:)

Creates an instance that uniquely identifies and creates slider ticks across updates based on the provided key path to the underlying data’s identifier.

Declaration

nonisolated init<V>(_ data: Data, id: KeyPath<Data.Element, ID>, @SliderTickBuilder<V> content: @escaping (Data.Element) -> Content) where V == Data.Element, Data.Element == Content.Value

Parameters

  • data:

    The data that the Foreach instance uses to create mark items dynamically.

  • id:

    The key path to the provided data’s identifier.

  • content:

    The builder that creates ticks dynamically.

Discussion

It’s important that the id of a data element doesn’t change, unless SwiftUI considers the data element to have been replaced with a new data element that has a new identity. If the id of a data element changes, then the marks generated from that data element will lose any current state and animations.