---
title: "textView(_:primaryActionFor:defaultAction:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uitextviewdelegate/textview(_:primaryactionfor:defaultaction:)"
---

# textView(_:primaryActionFor:defaultAction:)

Asks the delegate for the action to be performed when interacting with a text item. If a nil action is provided, the text view will request a menu to be presented on primary action if possible.

## Declaration

```swift
optional func textView(_ textView: UITextView, primaryActionFor textItem: UITextItem, defaultAction: UIAction) -> UIAction?
```

## Parameters

- `textView`: The text view requesting the primary action.
- `textItem`: The text item for performing said action.
- `defaultAction`: The default action for the text item. Return this to perform the default action.

## Return Value

Return Value Return a UIAction to be performed when the text item is interacted with. Return @c nil to prevent the action from being performed.

## See Also

### Interacting with text data

- [textView(_:menuConfigurationFor:defaultMenu:)](uikit/uitextviewdelegate/textview(_:menuconfigurationfor:defaultmenu:).md)
- [textView(_:textItemMenuWillDisplayFor:animator:)](uikit/uitextviewdelegate/textview(_:textitemmenuwilldisplayfor:animator:).md)
- [textView(_:textItemMenuWillEndFor:animator:)](uikit/uitextviewdelegate/textview(_:textitemmenuwillendfor:animator:).md)
