0
我正在構建一個應用程序,該應用程序使用Dave DeLong使用DDMathParser對給定函數的文本進行圖形化。如果解決方案存在,我需要知道(對於每個「x」我評估),或者它只是給我0.00,因爲它無法評估它。也許是布爾?DDMathParser - 如何識別錯誤是iOS
while (x <= (viewWidth - originOffsetX)/axisLenghtX) {
NSDictionary *variableSubstitutions = [NSDictionary dictionaryWithObject: [NSNumber numberWithDouble:x] forKey:@"x"];
NSString *solution = [NSString stringWithFormat:@"%@",[[DDMathEvaluator sharedMathEvaluator]
evaluateString:plotterExpression withSubstitutions:variableSubstitutions]];
numericSolution = solution.numberByEvaluatingString.doubleValue;
NSLog(@"%f", numericSolution);
if (newline) {
CGContextMoveToPoint(curveContext, (x*axisLenghtX + originOffsetX), (-numericSolution * axisLenghtY + originOffsetY));
newline = FALSE;
} else {
CGContextAddLineToPoint(curveContext, (x*axisLenghtX + originOffsetX), (-numericSolution * axisLenghtY + originOffsetY));
}
x += dx;
謝謝,這正是我一直在尋找! –