我試過各種方法,這些都給了我警告。如userName = [NSString stringWithFormat:@"%@", [yournamefield stringValue]];
這只是給了我如何將UITextField中的文本轉換爲NSString?
「的UITextField」的警告可能不會爲「-stringValue」
我怎麼做這個迴應?
userName = [NSString stringWithFormat:@"%@", yournamefield.text];
我試過各種方法,這些都給了我警告。如userName = [NSString stringWithFormat:@"%@", [yournamefield stringValue]];
這只是給了我如何將UITextField中的文本轉換爲NSString?
「的UITextField」的警告可能不會爲「-stringValue」
我怎麼做這個迴應?
userName = [NSString stringWithFormat:@"%@", yournamefield.text];
使用text
財產
NSString *name = yourNameField.text;
不!做**不**使用訪問器方法來明確定義公共頭中的屬性。 – PeyloW 2011-01-11 17:38:20
如何獲取文本字段中的文本。 這是一個屬性,任何屬性值可以這樣訪問 -
yournamefield.text
[yournamefield text]
使用的UITextField
的text
屬性:
NSString *userName = yourNameField.text;
兩種方式
http://developer.apple.com/library/ios/#documentation/uikit/ reference/UITextField_Class/Reference/UITextField.html#// apple_ref/doc/uid/TP40006888 – filipe 2011-01-11 17:07:24
`-stringValue`是`NSTextField`的一種方法 – NSGod 2011-01-11 18:45:28