views:

33

answers:

1

Hi, I would like to ignore all case sensitivity to be ignored for my UITextField and UITextView. I would also like to know how to detect if the string is upperCase or lowerCase. Thanks.

A: 

[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] == [[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]];
muffix