I am just starting out in xCode and I have built a very simple (mac, not iPhone) app that pops up a window with a text field, a label and a button.
I can get the app to pop up a message box with the string value of the text box, but I can’t seem to set the string value of the text field with some default text.
The code I am using to try to populate the text field is:
[_txtBox setStringValue:@"Hello World"];
the set string method is the only method that looks like it should set the value of the box. The program runs with no errors and when I click on the button, no error’s are thrown.
If the text field contains text, the text displays in the label as it should.
If I place the line of code above just before the code that reads and outputs the text field, then instead of the text box showing that text box, the text box text just disappears as if I had over written the contents of the field with an empty string. The label is also blank.
Suggestionsn would be welcome; the almost identical expression I am using on the label works fine:
[_lblOutPut setStringValue:_txtIP];
So I have no idea what I am doing wrong…
Cheers!
Dave
Check whether you are using “
NSTextFieldwithNumberFormatter” or “NSTextField“.“
NSTextFieldwithNumberFormatter” allows only numerals. If you try to setNSStringit will display only an empty string.Try this
Now, If you are getting 123 in your output, then definitely you are using “
NSTextFieldwithNumberFormatter“