This is quite simple. In your .h file:
@interface AppDelegate : NSObject <NSApplicationDelegate>
{
IBOutlet NSTextField *xPosTextBox;
}
- (IBAction)setXPos:(id)sender;
Be sure you connect both to your NSTextField in IB. For the next step I'll assume you have a number formatter in the text box and that xPos is a double. In applicationDidFinishLaunching:
[[xPosTextBox formatter] setFormat:@"##0.000"];
[xPosTextBox setDoubleValue:myInitialValue];
Then somewhere in your AppDelegate code add a method:
- (IBAction)setXPos:(id)sender
{
xPos = [xPosTextBox doubleValue];
}
easy.
if you have a float in applicationDidFinishLaunching:
[[xPosTextBox formatter] setFormat:@"##0.000"];
[xPosTextBox setFloatValue:myInitialValue];
Then the IBAction method:
- (IBAction)setXPos:(id)sender
{
xPos = [xPosTextBox floatValue];
}
If you have an int (or NSInteger), no need for the number formatter, so in applicationDidFinishLaunching:
[xPosTextBox setIntValue:myInitialValue];
// [xPosTextBox setIntegerValue:myInitialValue]; for NSInteger
Then the IBAction method:
- (IBAction)setXPos:(id)sender
{
xPos = [xPosTextBox intValue];
// xPos = [xPosTextBox integerValue]; for NSInteger
}