4

Possible Duplicate:
What is a fast C or Objective-C math parser?

I have a NSString which represents a calculation eg. @"(10+10)*2" and I want to evaluate the string as if it was actually something like this;

double result = (10+10)*2;

What is the most straightforward approach to take in iOS?

Community
  • 1
  • 1
Chris Bentley
  • 1,945
  • 18
  • 23

2 Answers2

4

Take a look at Dave DeLong's DDMathParser framework.

Caleb
  • 124,013
  • 19
  • 183
  • 272
  • Thanks. @itai-ferber already pointed to duplicate question which suggests DDMathParser as solution (see comment thread above)... so I already have this working. – Chris Bentley Mar 11 '12 at 05:40
2

You can use GCMathParser.

pät
  • 543
  • 3
  • 9
  • This worked out of the box in OS X but I'm having some difficulty getting this to work with iOS 5... It appears to need a little more tweaking that just replacing "#import " with "#import " - I'll look at it again after I check the other suggestions. Thanks. – Chris Bentley Mar 11 '12 at 02:28