Identify Language in iPhone

Introduction

In this article I will create a Single View application with a text view and a button from xib. In this we write something in the text view and click on the button to determine the language that the text is.

To understand it we use the following.

Step 1

Open XCode by double-clicking on it.

Step 2

Create a New XCode Project by clicking on it.

Step 3

Now select Single View Application and click on Next.

Step 4

Now provide your Product Name and Company Identifier.

Step 5

Select the location where you want to save your project and click on Create.

Step 6

Now we write the code.

ViewController.h

#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property(nonatomic,strong)IBOutlet UITextView *txt;
@property (retain, nonatomic) IBOutlet UIButton *btn;
@end

ViewController.m

#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
@synthesize txt,btn;
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (IBAction)btn:(id)sender {
NSLocale *language = [NSLocale currentLocale];
NSString *titleOFApplication = [language displayNameForKey:NSLocaleIdentifier value:[language localeIdentifier]];
self.txt.text = titleOFApplication;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)dealloc {
[btn release];
[super dealloc];
}
@end

Step 7

Finally we click on the Run button to show the output.

Step 8

Output1 in iPhone:

Output1-in-iPhone.png

Output2 in iPhone:

Output2-in-iPhone.png

Up Next
    Ebook Download
    View all
    Learn
    View all