Share on Google+Share on Google+

NSString uppercaseString

Advertisement
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. 

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:

Click to Download Code

Advertisements

Advertisement

Posted on: September 4, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.