问题
I have an NSTextField, and I need a button to reset the text of the field. How would I do that? I have been trying this:
[textBox setText:@""];
textbox.text = @"";
That does not work, but I have researched, and found nothing on how to set the text, only how to get the text.
回答1:
If it is OSX and NSTextField then use :
[textBox setStringValue:@""];
回答2:
Try this code:
theLabel.text = @"this is some text";
[self.view addSubView:theLabel];
Here, the label is the text field.
来源:https://stackoverflow.com/questions/14541619/reset-nstextfields-text-to-empty-string-settext-doesnt-work