🖼️ForEach
╱🚧 under construction -> View Groupings
SwiftUI ⟩ view ⟩ groupings ⟩ ForEach
ForEach
generates views for each element in a collection.
ForEach
requires that each element provide an id
,
either explicitly in the
ForEach
initializer,or by conforming to the Identifiable protocol.
// <collection> must conform to Identifiable
ForEach(collection) { element in
Text(element.name)
}
⭐️ 注意:
ForEach doesn’t get hit by the 10-view limit. ⭐️
ForEach 不一定是 View,也可能是其他東西,如:TableRowContent
(👉 See: 📜 協定)
Swift ⟩ Basic Behaviors ⟩ Identifiable
Last updated
Was this helpful?