views:

32

answers:

1

Hi All,

I want to compare all the strings entered in a textview of iphone. Once the user finishes with typing in textview I want to compare strings entered by the user.

How do I do it?

Please help

+1  A: 

I am not sure what you define "finishes with typing", here is my guess:

You have to set up your class become UITextViewDelegate and implements some methods:

  • If you want to get the text whenever the text changes, use:

- (void)textViewDidChange:(UITextView *)textView

  • If you want to get the text whenever the text view resign first responder, use:

- (void)textViewDidEndEditing:(UITextView *)textView

I also don't know what you define by comparing all the NSString. One way to do is put them into NSSet and NSSet itself will remove duplicates of NSString for you

vodkhang
imMobile
do you have this line of code : `self.textView.delegate = self`
vodkhang
hey Thanks...silly mistake by a beginer..for textViewDidEndEditing do I need to handle keyboard dismiss event?
imMobile
I think you don't need.
vodkhang
then how the textViewDidEndEditing will be activated? i mean if we hav cursor still in textview? Return key will add new line to textview
imMobile
oh, you mean that if your cursor still in text view. Even if you handle keyboard dismiss event, we cannot handle the return key, right, it is just add new line and don't dismiss the keyboard.
vodkhang