Re: real noob question
Re: real noob question
- Subject: Re: real noob question
- From: Kyle Sluder <email@hidden>
- Date: Mon, 19 Jan 2009 23:41:59 -0500
On Sat, Jan 17, 2009 at 11:41 PM, Richard Dammkoehler <email@hidden> wrote:
> NSDecimalNumber *num = [[NSDecimalNumber alloc] initWithString:"23.30"];
1) That's not an ObjC string, it's a C string. That will crash unless
you replace it with @"23.30".
2) If the current locale isn't one that uses a period as the decimal
separator, that is not a valid number.
3) You are invoking the parser to convert hard-coded digits into an
NSDecimalNumber instance. Why not just provide the number directly,
avoiding the parser altogether? It's a constant, there's no need to
make the framework do more interpretation on it than necessary.
--Kyle Sluder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden