Andrea F
Andrea F

Reputation: 733

Automatic typing password iphone

In my UIViewController I have 2 textfields. One called passwordtextfield and the other retype. Instead of having people actually retype their passwords I want it to automatically fill it in. Is this possible? I tried something that keeps on crashing.

[_passwordtextfield addTarget:self action:@selector(updateTextField:) forControlEvents:UIControlEventEditingChanged];


- (void)updateTextField:(id)sender{

    UITextField *retype =  ((UITextField *)_passwordtextfield).text;


    }

Upvotes: 0

Views: 70

Answers (2)

Dharmbir Singh
Dharmbir Singh

Reputation: 17535

There is no need to cast your text field. You can assign direct value of your text field.So

Write this line

   retypetextfield.text =  _passwordtextfield.text;

instead of

UITextField *retype =  ((UITextField *)_passwordtextfield).text;

Upvotes: 1

woz
woz

Reputation: 10994

I don't know why you want to do this, as mentioned in the comments, but to answer the question... It looks like you are creating a new UITextField in updateTextField instead of setting the text of one that exists. It should look something like this:

- (void)updateTextField:(id)sender{
    retypeFied.Text = _passwordtextfield.text;
}

Substitute whatever you named the pointer to your second field for retypeField.

Upvotes: 0

Related Questions