Thursday, December 06, 2012

Converting NSStrings to uppercase, lowercase and capitalizing each word in a string

NSString *str = @"easy tips for programming";
 
// Convert string to uppercase
NSString *upperStr = [str uppercaseStringWithLocale:[NSLocale currentLocale]];
NSLog(@"Upper Case: %@", upperStr);
 
// Convert string to caps
NSString *capStr = [upperStr capitalizedStringWithLocale:[NSLocale currentLocale]];
NSLog(@"Capital: %@", capStr);
 
// Convert string to lowercase
NSString *lowerStr = [capStr lowercaseStringWithLocale:[NSLocale currentLocale]];
NSLog(@"Lower Case: %@", lowerStr);
 
output:
Upper Case: EASY TIPS FOR PROGRAMMING
Capital: Easy Tips For Programming
lower Case: easy tips for programming
   
  

No comments:

Create a list in SwiftUI with sticky section headers

 Sample Code import SwiftUI struct ContentView : View {     @State var isCustomViewControllerDisplayed = false     @State private va...