My app uses text fields to let users login. The login viewcontroller has a total of 4 text field IBOutlets:
IBOutlet UITextField* fldUsername;
IBOutlet UITextField* fldPassword;
@property (nonatomic, retain) IBOutlet UITextField* nicknameTextField;
@property (nonatomic, retain) IBOutlet UITextField* secretCodeTextField;
How can one properly string the nickNameTextField
with whatever value the fldUsername
text field gets from the user? If fldUsername
gets a "JohnnyAppleseed" value from the user, I want nicknameTextField
to get the exact same value simultaneously. Proper way to achieve this using obkective c?
Thanks a lot for the updates @Jamil: I got it to work with the following line of code:
NSMutableDictionary* params =[NSMutableDictionary dictionaryWithObjectsAndKeys:command, @"command", _nicknameTextField.text = fldUsername.text, @"username", hashedPassword, @"password", nil];
Since it was already being used in for the login function, it worked by adding _nicknameTextField.text = fldUsername.text
you can achieve this, by implementing this delegate method.
first you need set tag of all 4 text field OR you have to check your current textfield other way
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string;{
//check this '**textField**' is **fldUsername** textfield
if(fldUsername.tag == textField.tag){
fldUsername.text = textField.text;
nicknameTextField.text = textField.text; //override what ever it's prevous value
}
}