Gopinath
Gopinath

Reputation: 5442

How can i get the first typed letter after empty space("") from UITextView in iPhone?

I want to get the last word from the typed sentence in UITextView. For example "Apple i", from this example i need to get the last letter 'i' coming after " "(empty space). I want to do the functionality while the user typing in UITextView. How can i get the users first letter of the word after from empty space(" ")? Can anyone please help to solve this problem? Thanks in advance.

Upvotes: 1

Views: 583

Answers (1)

Mundi
Mundi

Reputation: 80265

Here is the string logic.

return [[textView.text componentsSeparatedByString:@" "] lastObject];

You can put this check in your UITextViewDelegate method textView:shouldChangeTextInRange:replacementText:. Don't forget to return YES here. You could also use textViewDidChange:.

Upvotes: 1

Related Questions