I want to evaluate a string which is written in JavaScipt in iOS and learned I can to that by using:
[self.webView stringByEvaluatingJavaScriptFromString:formula]
The code I'm using is:
NSString *formula = @"( 1.5 * Math.pow(2, 3) ) / 12";
formula = [NSString stringWithFormat:@"eval('%@')", formula];
NSInteger value = [[self.webView stringByEvaluatingJavaScriptFromString:formula] integerValue];
The problem is the Math.pow function. If I dont use it , I get a real value form the webView. If I have Math.pow in the string, I just get empty string back. Can anyone help me how to change the code so I can use strings which contains Math.pow?