<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 11.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 7.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/DynamicViewContent/onInsert(of:perform:)-418bq",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI18DynamicViewContentPAAE8onInsert2of7performQrSay22UniformTypeIdentifiers6UTTypeVG_ySi_SaySo14NSItemProviderCGtctF"
  },
  "title" : "onInsert(of:perform:)"
}
-->

# onInsert(of:perform:)

Sets the insert action for the dynamic view.

```
nonisolated func onInsert(of supportedContentTypes: [UTType], perform action: @escaping (Int, [NSItemProvider]) -> Void) -> some DynamicViewContent
```

## Parameters

`supportedContentTypes`

An array of UTI types that the dynamic
view supports.

`action`

A closure that SwiftUI invokes when elements are added to
the view. The closure takes two arguments: The first argument is the
offset relative to the dynamic view’s underlying collection of data.
The second argument is an array of
<doc://com.apple.documentation/documentation/Foundation/NSItemProvider> items that
represents the data that you want to insert.

## Return Value

A view that calls `action` when elements are inserted into
the original view.

---

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)