比较UITextView中的文字? [英] Comparing text in UITextView?

查看:66
本文介绍了比较UITextView中的文字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们如何将 UITextVIew 中输入的文本与代码中的默认文本进行比较,以确定它们是否相同?

How can we compare the text entered in UITextVIew with my default text in code to determine whether they are both the same or not?

推荐答案

我认为这应该适合你:

虽然这是一个区分大小写的比较

Though this is a case sensitive comparison of string

 BOOL boolVal = [textView.text isEqualToString:@"My Default Text"];

以下是如何对字符串进行不区分大小写的比较:

Here is how you can do case insensitive comparison of string:

BOOL boolVal = [textView.text compare:@"My Default Text" options:NSCaseInsensitiveSearch]

如果 boolVal YES 那么你可以说那些字符串是相同的,他们是不同的。

Here if boolVal is YES then you can say that strings are same else they are different.

希望这对你有帮助。

这篇关于比较UITextView中的文字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆