Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make all characters lowercase in NSString?

How would I go about making all characters in an NSString lowercase?

like image 365
Will Coughlin Avatar asked Sep 03 '11 22:09

Will Coughlin


1 Answers

NSString has a cunningly named lowercaseString method.

NSString *noCaps = [yourString lowercaseString];

Edited to add

If you are asking how to change the actual string to be lowercase - you can't. NSStrings are immutable. They can't be changed after they have been created. If you want to change the string in place you should use an NSMutableString like so:

[aMutableString setString:[aMutableString lowercaseString]];
like image 149
Abizern Avatar answered Sep 21 '22 23:09

Abizern