New NSString Methods in iOS 6
October 29, 2012
iOS 6 introduced a few new methods for NSString objects, converting strings to uppercase, lowercase and capitalizing each word in a string.
The code below shows the three new string conversion methods:
NSString *str = @"mobile developer tips"; // Convert string to uppercase NSString *upperStr = [str uppercaseStringWithLocale:[NSLocale currentLocale]]; NSLog(@"upperStr: %@", upperStr); // Convert string to caps NSString *capStr = [upperStr capitalizedStringWithLocale:[NSLocale currentLocale]]; NSLog(@"capStr: %@", capStr); // Convert string to lowercase NSString *lowerStr = [capStr lowercaseStringWithLocale:[NSLocale currentLocale]]; NSLog(@"lowerStr: %@", lowerStr); |
The output from the code is shown in below:
![]()



