Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: rules
Fetching contributors…

Cannot retrieve contributors at this time

34 lines (27 sloc) 0.931 kB
//
// NSString+DDMathParsing.m
// DDMathParser
//
// Created by Dave DeLong on 11/21/10.
// Copyright 2010 Home. All rights reserved.
//
#import "NSString+DDMathParsing.h"
#import "DDExpression.h"
@implementation NSString (DDMathParsing)
- (NSNumber *) numberByEvaluatingString {
return [self numberByEvaluatingStringWithSubstitutions:nil];
}
- (NSNumber *) numberByEvaluatingStringWithSubstitutions:(NSDictionary *)substitutions {
NSError *error = nil;
NSNumber *returnValue = [self numberByEvaluatingStringWithSubstitutions:substitutions error:&error];
if (error != nil) {
NSLog(@"error: %@", error);
return nil;
}
return returnValue;
}
- (NSNumber *)numberByEvaluatingStringWithSubstitutions:(NSDictionary *)substitutions error:(NSError **)error {
DDExpression * e = [DDExpression expressionFromString:self error:error];
return [e evaluateWithSubstitutions:substitutions evaluator:nil error:error];
}
@end
Jump to Line
Something went wrong with that request. Please try again.