Converting all text to lower case in Objective-C

inFever picture inFever · Jan 1, 2012 · Viewed 55k times · Source

I have a textfield in my iOS app where the user is supposed to input some text. But I was wondering if there is any way to convert the users input to lowercase letters.

I remember in C# it was something like Convert.ToLower but I can't seem to figure out how to do it in Objective-C.

Answer

David Rönnqvist picture David Rönnqvist · Jan 1, 2012

There is a method called lowercaseString on NSString. NSString contains plenty of methods for string manipulation, please read the documentation.

NSString *myString = @"Hello, World!";
NSString *lower = [myString lowercaseString]; // this will be "hello, world!"