I would like to ask how could I convert a string which inserted by user to a Math equation so xCode would understand.
For example if user enter this to a text field. “2*sin(2*M_PI*t)” which the “t” inside the equation is a variable inside the code and Xcode would able understand the equation like
double answer = 2*sin(2*M_PI*t);
Many Thanks
Kin
You can do it with just the standard cocoa classes, but the syntax gets somewhat ridiculous, and the amount of set-up is staggering too.
A few pointers to note:
tin your expression became$tso that you could reference it from thevarsdictionaryM_PIbecame simplyPI; note the added method to support itFUNCTIONand a category is used to get around it.