Kyle Parisi
Kyle Parisi

Reputation: 1416

NSTextField will not update

[self.change setStringValue:[NSString stringWithFormat:@"%i", changeValue]];

where change is an IBOutlet of type NSTextField. For whatever reason I can not get the text field to display anything I want. Every time I run, the field is "0". Any ideas on why it won't change?

Upvotes: 2

Views: 1515

Answers (3)

Anoop Vaidya
Anoop Vaidya

Reputation: 46533

Never update textfield or pop-button in init. You have to fill default values in awakeFromNib or some other delegates once class gets initialized.

Upvotes: 3

Kyle Parisi
Kyle Parisi

Reputation: 1416

Ok here is the embarrassing rookie mistake for others to learn from. I was calling my setstringvalue before the view was even loaded; in the didfinishlaunching method. Use the awakefromnib method to make sure you view is loaded. Via Apple:

Finally, after all the objects are fully initialized, each receives an awakeFromNib message.

Upvotes: 1

Ramy Al Zuhouri
Ramy Al Zuhouri

Reputation: 21966

Verify that the outlet is really linked with the NSTextField you have put in the xib file.

Upvotes: 0

Related Questions