Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the text from UITextField into an NSString?

I've tried various methods, which all give me warnings. Such as userName = [NSString stringWithFormat:@"%@", [yournamefield stringValue]]; which just gives me a warning of

'UITextField' may not respond to '-stringValue'

How do i do this?

like image 545
Andrew Avatar asked Jan 11 '11 16:01

Andrew


3 Answers

Get the text inside the text field using the text property

NSString *name = yourNameField.text;
like image 150
Jilouc Avatar answered Nov 17 '22 15:11

Jilouc


Use the text property of UITextField:

NSString *userName = yourNameField.text;
like image 31
Eric Chai Avatar answered Nov 17 '22 16:11

Eric Chai


How about:

userName = [NSString stringWithFormat:@"%@", yournamefield.text];
like image 1
badgerr Avatar answered Nov 17 '22 14:11

badgerr