Home > DeveloperSection > Forums > How to get value from text field on button click in iOS?
Jayden Bell
Jayden Bell

Total Post:110

Posted on    December-19-2015 12:59 AM

 iPhone iPhone  Ios  Objective C 

 1 Reply(s)
 525  View(s)
Rate this:

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

-(IBAction) login: (id)sender{

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?

Tarun Kumar

Total Post:214

Posted on    December-20-2015 11:44 PM

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:

  NSString *username = [textFieldUserName stringValue];
  NSString *password = [textFieldPassword stringValue];

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

Don't want to miss updates? Please click the below button!

Follow MindStick