I want to get the last word entered by the user from a UITextView.
The user can enter the word anywhere in the UITextView, in the middle or at the end or at the beginning. I would think that this word when the user finishes typing it and presses the space bar and makes any corrections using the "Suggestions from UIMenuController ".
Example. The user-defined types in "kimd" in a UITextView somewhere in the middle of the text, it gets a popup for auto-correction of the "kind" that it does. After that, I want to capture the “view” and use it in my application.
I searched a lot on the Internet, but found solutions that talk about when the user enters text at the end. I also tried to find a space and then do a reverse search until the next space after any text was found so that I could qualify it as a word. But I think there may be better ways to do this.
I read somewhere that iOS caches recent text that we enter in a text box or text view. If I can pull out the top, then all I want. I just need to process this object.
I am very grateful for the help.
Note. The user can enter text anywhere in the UItextview. I need the last word entered
Thanks.
source share