简体   繁体   English

在iPhone的TextView中比较多个字符串

[英]Compare multiple strings in textview of iphone

I want to compare all the strings entered in a textview of iphone. 我想比较在iphone的textview中输入的所有字符串。 Once the user finishes with typing in textview I want to compare strings entered by the user. 用户输入完textview后,我想比较用户输入的字符串。

How do I do it? 我该怎么做?

Please help 请帮忙

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: 您必须将您的类设置为UITextViewDelegate并实现一些方法:

  • 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. 我也不知道您通过比较所有NSString定义了什么。 One way to do is put them into NSSet and NSSet itself will remove duplicates of NSString for you 一种方法是将它们放入NSSetNSSet本身将为您删除NSString重复项

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM