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

Published by Mandar Apte

Mandar is a Mumbai-based multi-disciplinary designer with UX/UI, Logo, Symbol, and Brand Identity design expertise. He currently runs his Mudrkashar Linguistic Apple iPhone, iPad, and Mac app business in the heart of Mumbai city.

Leave a comment

Leave a Reply