<!--
{
  "availability" : [
    "iOS: 3.2.0 -",
    "iPadOS: 3.2.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UITextInputStringTokenizer",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UITextInputStringTokenizer"
  },
  "title" : "UITextInputStringTokenizer"
}
-->

# UITextInputStringTokenizer

A base implementation of the text-input tokenizer protocol.

```
@MainActor class UITextInputStringTokenizer
```

## Overview

If you want to take advantage of this base implementation of the [`UITextInputTokenizer`](/documentation/UIKit/UITextInputTokenizer) protocol, you should subclass this class and handle application-specific directions and granularities affected by layout. When you instantiate a class you must supply the document class that’s adopting the [`UITextInput`](/documentation/UIKit/UITextInput) protocol for your application.

### Subclassing notes

When you subclass [`UITextInputStringTokenizer`](/documentation/UIKit/UITextInputStringTokenizer), override all [`UITextInputTokenizer`](/documentation/UIKit/UITextInputTokenizer) methods, calling the superclass implementation (`super`) when method parameters aren’t affected by layout. For example, the subclass needs a custom implementation of all methods for line granularity. For the left direction, it needs to decide whether left corresponds at a given position to forward or backward, and then call `super` passing in the storage direction ([`UITextStorageDirection`](/documentation/UIKit/UITextStorageDirection)).

## Topics

### Initializing a tokenizer

[`init(textInput:)`](/documentation/UIKit/UITextInputStringTokenizer/init(textInput:))

Returns an object initialized with the document object that directly communicates with the text input system.



---

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)