I am fairly new to programming and am working with Objective-C in Xcode 5. I'm presently making an OSX application in Xcode that uses Cramer's Rule (this matrix math method to calculate the intersecting point of three lines).
I really need some help with this one concept- I need to be able to take the user's input from multiple text boxes (assign them all a variable), put them through cramer's rule, and feed the answer out through a label.
I've made the storyboard and assigned one of the 12 text boxes (to test it) as an outlet and the label as an outlet and a button as an action, and tried a few different ways to just take the user input and (unaltered) feed it back out through the label so I know what I'm working with before I get into the math, and it's been unsuccessful. Having major syntax problems.
I have attached my code below:
//
// NewClass.h
// Cramer's Rule
#import <Foundation/Foundation.h>
@interface NewClass : NSViewController <NSTextFieldDelegate> {
IBOutlet NSTextField *box_a;
IBOutlet NSTextField *coord;
NSString *string;
}
@property (nonatomic, retain) IBOutlet NSTextField *box_a;
@property (nonatomic, retain) IBOutlet NSTextField *coord;
- (IBAction)calculate:(id)sender;
@end
AND
//
// NewClass.m
// Cramer's Rule
#import "NewClass.h"
@implementation NewClass
@synthesize box_a;
@synthesize coord;
- (IBAction)calculate:(id)sender {
NSTextField * input=box_a;
coord =input;
}
@end
senderwill be the object (NSTextField) that triggered the action. It will also be accessible as self.box_a as that is the property you have bound in Image Builder. You need to use the a method, such as thestringValuemethod to access the content of an NSTextField. So you probably want[self.coord setStringValue:[(NSTextField *)sender stringValue];