Adam
Adam

Reputation: 73

How to get a string from a UITextField?

How would I go about getting a string from a UITextField in the iPhone SDK? I'm trying to insert it into another concatenated string.

Upvotes: 5

Views: 9218

Answers (4)

Bilal
Bilal

Reputation: 11

for Swift 3.0

place these lines where you need

let yourString: String = ""

yourString = textField.text

Actually text attribute of textField provide the value to String.

Upvotes: 0

Rakesh Bhatt
Rakesh Bhatt

Reputation: 4606

lblAns.text=[NSString stringWithFormat:@"%i",[[txtField1 text] intValue] + [[txtField2 text] intValue]];

you can do addition of two textboxs value like this...

Upvotes: 0

Pankaj Kainthla
Pankaj Kainthla

Reputation: 2489

NSString *s = textfield.text;

yourString = [yourString appendString:s];

Upvotes: 0

Chris Long
Chris Long

Reputation: 3084

This should do it:

NSString *myString = myTextField.text;

Upvotes: 15

Related Questions