Skip to content

Instantly share code, notes, and snippets.

@esafwan
Last active December 26, 2015 14:09
Show Gist options
  • Save esafwan/7163726 to your computer and use it in GitHub Desktop.
Save esafwan/7163726 to your computer and use it in GitHub Desktop.
Getting Value from test field in objective C and setting it to another textfield.
#import <Cocoa/Cocoa.h>
@interface AppDelegate : NSObject <NSApplicationDelegate>
//The UI have a pushbutton, textfield1 & textfield2.
//create an action for push button with below code. (ctrl + drag to AppDelegate.h)
- (IBAction)button:(id)sender;
//create an outlet for each text fields textfield. (ctrl + drag to AppDelegare.h)
@property (weak) IBOutlet NSTextField *textField1;
@property (weak) IBOutlet NSTextField *textField2;
@end
#import "AppDelegate.h"
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// Insert code here to initialize your application
}
//And then in AppDelegate.m file
//Below code takes value from textField2 and puts in textField1.
- (IBAction)button:(id)sender {
[self.textField1 setFloatValue:[self.textField2 intValue]];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment