开发者

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

开发者 https://www.devze.com 2023-02-04 04:03 出处:网络
I\'ve tried various methods, which all give me warnings. Such as userName = [NSString stringWithFormat:@\"%@\", [yournamefield stringValue]]; which just gives me a warning of

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 '-stringVa开发者_StackOverflow社区lue'

How do i do this?


Get the text inside the text field using the text property

NSString *name = yourNameField.text;


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]
0

精彩评论

暂无评论...
验证码 换一张
取 消