Hello, I am new to cocoa programing, and am trying to develop a simple program that has one button and two NSTextFields, the object of the program is, that once you press the button one of the NSTextFields subtract its value from the other NSTextFields.
I have the compiler saying there aren't any errors, but when I click on the button nothing happens. I have everything in Interface Builder set up right, so I imagine it must be a code problem
Here is the code for it
MyController.h
MyController.m
I have the compiler saying there aren't any errors, but when I click on the button nothing happens. I have everything in Interface Builder set up right, so I imagine it must be a code problem
Here is the code for it
MyController.h
Code:
#import <Cocoa/Cocoa.h>
@interface MyController : NSObject {
IBOutlet NSTextField *amount;
IBOutlet NSTextField *amountToSubtract;
float myAmount;
float myAmountToSubtract;
}
- (IBAction)subtract:(id)sender;
@end
MyController.m
Code:
@implementation MyController
- (IBAction)subtract:(id)sender {
myAmount = [amount floatValue] - [amountToSubtract floatValue];
[amount stringWithFormat:@"%f", myAmount ];
}
@end