Interface Redesign to show evaluation results
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
//
|
||||
|
||||
#import "MPDocument.h"
|
||||
#import "MPView.h"
|
||||
|
||||
@implementation MPDocument
|
||||
|
||||
@@ -30,6 +29,8 @@
|
||||
- (void)windowControllerDidLoadNib:(NSWindowController *)aController
|
||||
{
|
||||
[super windowControllerDidLoadNib:aController];
|
||||
self.expressionView.target = self;
|
||||
self.expressionView.action = @selector(evaluateExpression:);
|
||||
// Add any code here that needs to be executed once the windowController has loaded the document's window.
|
||||
}
|
||||
|
||||
@@ -58,12 +59,11 @@
|
||||
}
|
||||
|
||||
#pragma mark Actions
|
||||
- (IBAction)evaluateExpressiom:(id)sender {
|
||||
NSError *error;
|
||||
NSLog(@"Result: %f", [self.resultExpressionView.expressionStorage evaluateExpression:&error]);
|
||||
if (error) {
|
||||
NSLog(@"Error: %@", error);
|
||||
}
|
||||
- (IBAction)evaluateExpression:(id)sender {
|
||||
MPParseError *error;
|
||||
NSDecimalNumber *result = [self.expressionView.expressionStorage evaluateWithError:&error];
|
||||
self.resultLabel.stringValue = result != nil ? result.description : @"Error!";
|
||||
self.errorLabel.stringValue = error != nil ? error.description : @"No Error";
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user