---
title: "setMarkedText(_:selectedRange:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uitextdocumentproxy/setmarkedtext(_:selectedrange:)"
---

# setMarkedText(_:selectedRange:)

Inserts the provided text and marks it to indicate that it’s part of an active input session.

## Declaration

```swift
func setMarkedText(_ markedText: String, selectedRange: NSRange)
```

## Mentioned in

Handling text interactions in custom keyboards

## Discussion

Discussion Setting marked text either replaces the existing marked text or, if none is present, inserts it in place of the current selection.

## See Also

### Managing marked text

- [unmarkText()](uikit/uitextdocumentproxy/unmarktext().md)
