---
title: "onInsert(of:perform:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/dynamicviewcontent/oninsert(of:perform:)"
---

# onInsert(of:perform:)

Sets the insert action for the dynamic view.

## Declaration

```swift
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

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

## See Also

### Responding to updates

- [onDelete(perform:)](swiftui/dynamicviewcontent/ondelete(perform:).md)
- [onMove(perform:)](swiftui/dynamicviewcontent/onmove(perform:).md)
- [dropDestination(for:action:)](swiftui/dynamicviewcontent/dropdestination(for:action:).md)
