简体   繁体   中英

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?

使用text属性在文本字段中获取text

NSString *name = yourNameField.text;

使用UITextFieldtext属性:

NSString *userName = yourNameField.text;

Two ways. It is a property and any property value can be accessed like this -

  • yournamefield.text
  • [yournamefield text]

怎么样:

userName = [NSString stringWithFormat:@"%@", yournamefield.text];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM