[英]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]];
例如userName = [NSString stringWithFormat:@"%@", [yournamefield stringValue]];
which just gives me a warning of 这只是给了我一个警告
'UITextField' may not respond to '-stringValue' 'UITextField'可能无法响应'-stringValue'
How do i do this? 我该怎么做呢?
使用text
属性在文本字段中获取text
NSString *name = yourNameField.text;
使用UITextField
的text
属性:
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];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.