0

Sorry for my english, I try to explain better my problem: I need to parse a math expression and then save the results inside a variable, this is my code:

for (i = -100; i < 100; i = i + step) {
    NSError *error = nil;
    NSDictionary *variableSubstitutions = [NSDictionary dictionaryWithObject:[NSNumber numberWithDouble:i] forKey:@"x"];
    NSNumber *y = [[DDMathEvaluator sharedMathEvaluator] evaluateString:[self convertString:eq.equazione] withSubstitutions:variableSubstitutions error:&error];
    NSLog(@"y is: %@",y);
}

The NSLog have always a value, if I try to parse an expression like tan(x) the log never print a nil value, I need to display also the nil value if exist. I try to check y value, error value but I don't find a way for handle nil value of expression.

zaph
  • 111,848
  • 21
  • 189
  • 228
francesco.venica
  • 1,703
  • 2
  • 19
  • 54

1 Answers1

0

This is probably not what you want, if not please update your question.

NSNumber *y = [[DDMathEvaluator sharedMathEvaluator] evaluateString:[self convertString:eq.equazione] withSubstitutions:variableSubstitutions error:&error];
if(y)
    NSLog(@"y is: %@", y);
else
    NSLog(@"y is: nil");
zaph
  • 111,848
  • 21
  • 189
  • 228