I have a UITextView and I use its tokenizer to check what words the user clicks.
My goal is to change what the tokenizer thinks like a word. Currently, it seems that words are defined as consecutive alphanumeric characters, I want the word to be defined as consecutive characters that are not a space character ("").
For example: "foo-bar", "foo / bar" and "foo @@ bar" will currently be treated as two separate words ("foo" and "bar"), but I want everyone to treat them as one word (since none of them contain spaces).
The documentation says about a subclass of the UITextInputStringTokenizer class, but I cannot find a single example of who does this, and I cannot understand how I would like to implement the necessary methods:
func isPosition(position: UITextPosition, atBoundary granularity: UITextGranularity, inDirection direction: UITextDirection) -> Bool func isPosition(position: UITextPosition, withinTextUnit granularity: UITextGranularity, inDirection direction: UITextDirection) -> Bool func positionFromPosition(position: UITextPosition, toBoundary granularity: UITextGranularity, inDirection direction: UITextDirection) -> UITextPosition? func rangeEnclosingPosition(position: UITextPosition, withGranularity granularity: UITextGranularity, inDirection direction: UITextDirection) -> UITextRange?
ios objective-c tokenize swift uitextview
Joshua burr
source share