Archived
1
This repository has been archived on 2022-08-08. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
mathpad/MathPad/MPParsedNumber.m
2014-09-13 23:16:44 +02:00

43 lines
900 B
Objective-C

//
// 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