<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/ForEach/init(_:content:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftUI",
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI7ForEachV08_MapKit_aB0AD0E7ContentR0_rlE_7contentACyxq_q0_Gx_q0_7ElementQzctcAH_2IDQZRs_s12IdentifiableAIRQrlufc::OverloadGroup"
  },
  "title" : "init(_:content:)"
}
-->

# init(_:content:)

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

```
@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`](/documentation/SwiftUI/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.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)