HOW TO GET VALUE FROM TEXT FIELD ON BUTTON CLICK IN IOS?

Jayden Bell

Total Post:110

Points:774
Posted by  Jayden Bell
 605  View(s)
Ratings:
Rate this:

I have created a UIButton which is connected with the 'login' IBAction.
like this:

-(IBAction) login: (id)sender{
  NSLog(@"ButtonClicked");
}

but now, I wired that button with the two UITextField's and named them username and password. For getting value I use 'takeStringValueFrom' but I don't understand how to get those values?

  1. Tarun Kumar

    Post:214

    Points:1642
    Re: How to get value from text field on button click in iOS?

    Here, I am explaining your problems solution through our example.
    I have also created a login form and declare two textfield IBOutlets and named them textFieldUserName, textFieldPassword. and hook them into the Interface Builder.
    Now, if we want to get string values from that outlets, use this code:

    -(IBAction)login:(id)sender
    {
      NSString *username = [textFieldUserName stringValue];
      NSString *password = [textFieldPassword stringValue];
    }

      Modified On Dec-20-2015 11:48:01 PM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!