<!--
{
  "availability" : [
    "iOS: 13.0.0 - 27.0.0",
    "iPadOS: 13.0.0 - 27.0.0",
    "macCatalyst: 13.0.0 - 27.0.0",
    "macOS: 10.15.0 - 27.0.0",
    "tvOS: 13.0.0 - 27.0.0",
    "visionOS: 1.0.0 - 27.0.0",
    "watchOS: 6.0.0 - 27.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/DynamicViewContent/onInsert(of:perform:)-40hwa",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI18DynamicViewContentPAAE8onInsert2of7performQrSaySSG_ySi_SaySo14NSItemProviderCGtctF"
  },
  "title" : "onInsert(of:perform:)"
}
-->

# onInsert(of:perform:)

Sets the insert action for the dynamic view.

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

## Parameters

`acceptedTypeIdentifiers`

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 `NSItemProvider` 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)