<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "FoundationModels",
  "identifier" : "/documentation/FoundationModels/DynamicInstructionsForEach",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Foundation Models"
    ],
    "preciseIdentifier" : "s:16FoundationModels26DynamicInstructionsForEachV"
  },
  "title" : "DynamicInstructionsForEach"
}
-->

# DynamicInstructionsForEach

Dynamic instructions that produce content for each element of a collection.

```
struct DynamicInstructionsForEach<Data, ID, Content> where Data : RandomAccessCollection, ID : Hashable, Content : DynamicInstructions
```

## Overview

Don’t use this type directly. Instead, use [`DynamicInstructions.ForEach`](/documentation/FoundationModels/DynamicInstructions/ForEach) within the
`body` of your [`DynamicInstructions`](/documentation/FoundationModels/DynamicInstructions).

## Topics

### Creating an instance

[`init(Data, content: (Data.Element) -> Content)`](/documentation/FoundationModels/DynamicInstructionsForEach/init(_:content:))

Creates dynamic instructions that produce content for each element of an identifiable
collection.

[`init(Data, id: KeyPath<Data.Element, ID>, content: (Data.Element) -> Content)`](/documentation/FoundationModels/DynamicInstructionsForEach/init(_:id:content:))

Creates dynamic instructions that produce content for each element of a collection.

## Relationships

### Conforms To

[`DynamicInstructions`](/documentation/FoundationModels/DynamicInstructions)

---

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)