Contents

replaceText(_:withText:options:completionHandler:)

Replace the specified text preceding the current selection.

Declaration

func replaceText(_ originalText: String, withText replacementText: String, options: BETextReplacementOptions = [], completionHandler: @escaping  @Sendable ([UITextSelectionRect]) -> Void)
func replaceText(_ originalText: String, withText replacementText: String, options: BETextReplacementOptions = []) async -> [UITextSelectionRect]

Discussion

Completion handler should be invoked with the rects representing the replacementText. If the replaceText could not be completed succesfully, such as when the originalText no longer matches the current text, then the completion handler should be invoked with an empty array.