Redesign of the Evaluation System
This commit is contained in:
42
MathPad/MPParsedNumber.m
Normal file
42
MathPad/MPParsedNumber.m
Normal file
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// MPParsedNumber.m
|
||||
// MathPad
|
||||
//
|
||||
// Created by Kim Wittenburg on 13.09.14.
|
||||
// Copyright (c) 2014 Kim Wittenburg. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MPParsedNumber.h"
|
||||
|
||||
@interface MPParsedNumber ()
|
||||
@property (nonatomic) NSRange range;
|
||||
@property (nonatomic, strong) NSDecimalNumber *number;
|
||||
@end
|
||||
|
||||
@implementation MPParsedNumber
|
||||
|
||||
- (instancetype)initWithRange:(NSRange)range
|
||||
inString:(NSString *)string
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_range = range;
|
||||
if (range.location != NSNotFound) {
|
||||
NSString *stringValue = [string substringWithRange:range];
|
||||
_number = [NSDecimalNumber decimalNumberWithString:stringValue];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)exists
|
||||
{
|
||||
return self.range.location != NSNotFound;
|
||||
}
|
||||
|
||||
- (NSDecimalNumber *)evaluateWithError:(MPParseError *__autoreleasing *)error
|
||||
{
|
||||
return self.number;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user