0

I have an array which I want to validate: {"2","+","3","=","5"}

So how would I do it? I found DDMathParser and theoretically I would be able to validate my expression like so:

NSString *expression = [array componentsJoinedByString:@""];


NSError *error = nil;
DDExpression *e = [DDExpression expressionFromString:expression error:&error];
if (error == nil) {
    NSLog(@"parsed: %@", e);
    NSNumber * result = [e evaluateWithSubstitutions:expression error:&error];
    //error: No visible @interface for 'DDExpression' declares the selector 'evaluateWithSubstitutions:error:' 
}

Any thoughts why? I must mention this method is inside my singleton but when I moved it to my view controller error stayed.

Vad
  • 3,658
  • 8
  • 46
  • 81
  • Have you added `DDExpression.m` to your target? Have imported the `DDExpression.h` or just using a forward class declaration (`@class`)? – Mike D Feb 26 '13 at 17:17
  • @MikeD: I used #import "DDMathParser.h" – Vad Feb 26 '13 at 17:20

1 Answers1

2

Assuming you are using this project (GiHub link), I did not see a method evaluateWithSubstitutions:error:.

From the GitHub project, it looks like the full method signature is (source, line 33):

- (NSNumber *) evaluateWithSubstitutions:(NSDictionary *)substitutions evaluator:(DDMathEvaluator *)evaluator error:(NSError **)error;
Mike D
  • 4,938
  • 6
  • 43
  • 99