Question

Are there any methods for taking a string and converting all lowercase letters to uppercase? I was thinking of making a for-loop to run through, check each character, see if it is in range 0061-007A (lowercase letters) and just subtracting 26 (base 16) (converts to the uppercase counterpart) from the unicode code and adding that character back to the string.

But I figured I'd check if there is a simpler method already out there... googled but couldn't find anything... I'm sure I could use a 1x1 UIWebView and load some javascript (that does this) with my string into the UIWebView but there has got to be something already in Objective-C other than the manual approach I first mentioned right?

Was it helpful?

Solution

You do not need a loop - you can use either

NSString *upper = [src uppercaseString];

or

NSString *upper = [src uppercaseStringWithLocale:myLocale];

for targeting a specific locale.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top