Here is how to set the text in an NSTextField programatically in Xcode while developing applications for OSX?

Here is step wise how to set text in NSTextField programatically,

 
First,
If you are using storyboards for app development.
Connect button storyboard to code class file i.e. .h header & .m method file or incase of swift class file of source code

 
Second,
Let assume that you have connected your NSTextField / Label as:

 

@property (nonatomic, assign) IBOutlet NSTextField *namedTextField;

 
Third,
So you will use dot operator called .stringValue & Here is how it can be done two ways:

 
First Way:

 

self.namedTextField.stringValue = @“App Name”;

 
Second Way:

 

[self.namedTextField setStringValue:pointerName];

 
Precaution: Make sure your textfield variable is not null

 
Hope it helps,

 
Thanks & Regards
Mandar Apte

Mandar Apte

This website contains a design articles blog by Mandar Apte. He writes and shares his iOS development, graphic, web, & animation film design experience through articles. Mandar is Mumbai based multi-disciplinary designer with expertise in UI, UX, Logo, Symbol, and Brand Identity design. He is an alumnus of Sir J. J. Institute of Applied Art, Mumbai. He currently runs his studio in the heart of the city of Mumbai.

Leave a Reply

Your email address will not be published. Required fields are marked *