---
title: "How to get value from text field on button click in iOS?"  
description: "How to get value from text field on button click in iOS?"  
author: "Jayden Bell"  
published: 2015-12-19  
updated: 2015-12-20  
canonical: https://www.mindstick.com/forum/33753/how-to-get-value-from-text-field-on-button-click-in-ios  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 1 minute  

---

# How to get value from text field on button click in iOS?

I have created a UIButton which is [connected](https://www.mindstick.com/articles/12941/link-building-and-search-engine-rankings-how-are-they-connected) with the '[login](https://www.mindstick.com/articles/12852/styles-login-form-in-android)' IBAction.\
like this:

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

but [now](https://yourviews.mindstick.com/view/81402/it-s-liberals-vs-progressives-in-us-politics-now), I wired that [button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net) with the two UITextField's and [named](https://answers.mindstick.com/qa/44918/what-is-a-no-day-yet-named-motion) them [username and password](https://www.mindstick.com/forum/160407/how-does-a-bearer-token-differ-from-other-authentication-methods-such-as-username-and-password). For getting [value](https://www.mindstick.com/articles/23219/an-optimized-description-adds-value-to-experience-and-in-turn-effectively-guest-posting-packages) I use 'takeStringValueFrom' but I don't understand how to get those [values](https://www.mindstick.com/forum/327/sum-textbox-values)?

## Replies

### Reply by Tarun Kumar

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];}
```


---

Original Source: https://www.mindstick.com/forum/33753/how-to-get-value-from-text-field-on-button-click-in-ios

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
