iPhone NSString uppercaseString()
In the previous example we have seen that how to change first character of string into upper case. But in this "NSString uppercaseString" example, we are going to show you how to convert all the string into upper case.
The main purpose of using "uppercaseString" of NSString is to converting lowercase to upper case string.
Syntax for NSString uppercaseString:
|
NSString *upperString = [[NSString alloc] initWithFormat:string1]; NSString* changeString = [upperString uppercaseString]; |
The application is window based, you see the code given below...
uppercaseStringAppDelegate.h
|
#import <UIKit/UIKit.h> @interface uppercaseStringAppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; IBOutlet UIButton *button; } @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) IBOutlet UIButton *button; -(IBAction) uppercaseString:(id)sender; @end |
uppercaseStringAppDelegate.m
|
#import "uppercaseStringAppDelegate.h" @implementation uppercaseStringAppDelegate @synthesize window; @synthesize button; -(IBAction) uppercaseString:(id)sender { NSString *string1 = @"roseindia"; NSString *upperString = [[NSString alloc] initWithFormat:string1]; NSString* changeString = [upperString uppercaseString]; NSLog(changeString); } - (void)applicationDidFinishLaunching:(UIApplication *)application { // Override point for customization after application launch [window makeKeyAndVisible]; } - (void)dealloc { [window release]; [button release]; [super dealloc]; } @end |
The NSString uppercaseString application will give the following output:

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.