Hi all,
Thanks for the ideas. Im using the class method to evaluate such
strings, thusly:
-(NSNumber *) getNumberFrom: (NSString *) str {
NSScanner *scanner = [NSScanner scannerWithString: str];
int numerator, denominator;
[scanner scanInt: &numerator];
[scanner scanString:@"/" intoString: NULL];
[scanner scanInt: &denominator];
float result = (float) numerator/denominator;
NSNumber *nm = [NSNumber numberWithFloat: result];
return nm;
}
- Sandeep
On Tue, Feb 26, 2008 at 1:27 PM, Hamish Allan <[EMAIL PROTECTED]> wrote:
> On Tue, Feb 26, 2008 at 6:12 PM, Jean-Daniel Dupas
> <[EMAIL PROTECTED]> wrote:
>
> > As far as I know, there is no Math expression parser buit-in Cocoa.
> > You will have to write your own evaluator to do this.
>
> Or use e.g. NSTask with 'bc' (remembering to specify a scale for bc).
>
> Hamish
>
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [EMAIL PROTECTED]