obozhdi
obozhdi

Reputation: 33

grab text from one textField, change it and pass to another textField

I have 2 textfields and a button. in first I enter text. in second I get the changed text.

#import "tcViewController.h"

@interface tcViewController ()

@end

@implementation tcViewController

- (void)viewDidLoad {
[super viewDidLoad];
self.textField.delegate = self;
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
return NO;
}

- (IBAction)changeText:(id)sender {
_textField2.text = _textField.text;
}

@end

how can I change text for example from "text" to "TEXT" when pressing a button?

Upvotes: 1

Views: 87

Answers (2)

Dipu Rajak
Dipu Rajak

Reputation: 693

- (IBAction)changeText:(id)sender {
    _textField2.text = [_textField.text uppercaseString];

}

Upvotes: 2

Davi Stuart
Davi Stuart

Reputation: 269

You just have to make:

[_textField2 setText:[_textField.text uppercaseString]];

Upvotes: 2

Related Questions