Initializer

init(_:id:content:)

Creates an instance that uniquely identifies and creates views across updates based on the identity of the underlying data. あるインスタンスを作成します、それは、ビューそれらを更新を越えてその基礎をなすデータの同一性に基づいて特有に識別および作成するものです。

Declaration 宣言

init<C>(_ data: Binding<C>, id: KeyPath<C.Element, ID>, content: @escaping (Binding<C.Element>) -> Content) where Data == LazyMapSequence<C.Indices, (C.Index, ID)>, C : MutableCollection, C : RandomAccessCollection, C.Index : Hashable
Available when Data conforms to RandomAccessCollection, ID conforms to Hashable, and Content conforms to View. DataRandomAccessCollectionに準拠する、IDHashableに準拠する、そしてContentViewに準拠する時に利用可能です。

Parameters パラメータ

data

The identified data that the ForEach instance uses to create views dynamically. 識別されたデータ、それはForEachインスタンスが使用してビューを動的に作成するものです。

content

The view builder that creates views 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. 重要なことは、あるデータ要素のidは変化しないことです、あなたがそのデータ要素を新しい同一性を持つ新しいデータ要素と置き換えない限りは。あるデータ要素のidが変化するならば、そのデータ要素から生成されたコンテンツビューは、あらゆる現在の状態とアニメーションを失います。

See Also 参照

Creating a Collection from Data