Converting string equation to int
Converting string equation to int
- Subject: Converting string equation to int
- From: Christopher Drum <email@hidden>
- Date: Fri, 11 Feb 2005 16:54:04 -0800
Does anyone know a Cocoa method that will accept an equation as an
NSString and evaluate it to achieve an int (or long, or whatever). I
want to be able to do something like:
NSString *equation = @"7+5";
int x = [equation intValue];
NSLog(@"equation evaluates to: %i", x);
Unfortunately, intValue doesn't seem to look at a string as an
evaluatable equation, and I get 7 as the result rather than 12. Cocoa
seems to stop as soon as it reaches a non-numeric character.
I feel like there is some easy way to get this to work that I am
overlooking. Any ideas?
------------------------------------------------------------------
Christopher Drum
http://homepage.mac.com/christopherdrum
Check out FileWrangler, my five-star rated (MacUpdate, VersionTracker)
Cocoa app written in Objective-C for the batch renaming of files.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden