Comparing text in UITextView?

后端 未结 4 984
感动是毒
感动是毒 2021-01-29 10:08

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?

4条回答
  •  没有蜡笔的小新
    2021-01-29 10:38

    You can use the methods of NSString for this.

    1: isEqualToString: (case-sensitive)

    if( [ myString isEqualToString: otherString ] )
    {}
    

    2: caseInsensitiveCompare: (case-insensitive)

    if( [ myString caseInsensitiveCompare: otherString ] )
    {}
    

    3: localizedCaseInsensitiveCompare: (case-insensitive and localized)

    if( [ myString localizedCaseInsensitiveCompare: otherString ] )
    {}
    

提交回复
热议问题