Re: Converting a NSString into a math opertation
Re: Converting a NSString into a math opertation
- Subject: Re: Converting a NSString into a math opertation
- From: Itrat Khan <email@hidden>
- Date: Thu, 20 Jun 2002 21:23:45 -0400
On Wednesday, June 19, 2002, at 05:56 PM, Rodrigo Varela Tabuyo wrote:
I have the following problem: my application has an custom view where
users type math formulas, which are being kept as NSString. There are
several objects that use this formula with different values. I am
trying to avoid calls to a method which splits the string and
identifies the right pieces of string with math operations, with just
different parameters, doing all over again each time a value from that
formula is needed. What I need to know is if there is a way of
converting a NSString directly into a math function like the following
example:
Take a look at the example code in
/Developer/Examples/InterfaceBuilder/BusyPalette/. It shows how to
create an NSNumberFormatter subclass that evaluates expression strings.
Or, pick up a 2nd year comp. sci. algorithm text book and look for infix
expression evaluation (or search the Web). It's pretty straightforward
to implement.
And if you don't want to evaluate the result each time, cache it, and
invalidate the cache whenever the expression string changes.
Itrat.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.