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?
Jilouc
Get the text inside the text field using the text property
NSString *name = yourNameField.text;
Eric Chai
Use the text property of UITextField:
NSString *userName = yourNameField.text;
How about:
userName = [NSString stringWithFormat:@"%@", yournamefield.text];
Two ways. It is a property and any property value can be accessed like this -
yournamefield.text[yournamefield text]
来源:https://stackoverflow.com/questions/4660200/how-do-i-get-the-text-from-uitextfield-into-an-nsstring