Ignore case UITextField/UITextView
I would like to ignore all case sensitivity to be ignored for my UITextField and开发者_JAVA技巧 UITextView. I would also like to know how to detect if the string is upperCase or lowerCase. Thanks.
[myString uppercaseString] will give you the myString variable transformed to use only uppercase letters, [myString lowercaseString] will give you the lowercase version, respectively.
You can use it to check for uppercase (lowercase) strings like this:
if ([[textField text] isEqualToString:[[textField text] uppercaseString]]) {
NSLog("String is uppercase!");
}
If you have a reference string and want to compare it ignoring the case, you can just use caseInsensitiveCompare: method of NSString:
[referenceString caseInsensitiveCompare:[textField text]];
精彩评论