Re: Number Formatting
Re: Number Formatting
- Subject: Re: Number Formatting
- From: Chris Hanson <email@hidden>
- Date: Mon, 25 Aug 2003 16:08:53 -0500
On Monday, August 25, 2003, at 03:14 PM, Daniel Todd Currie wrote:
I'm working on a scientific application that requires number
formatting based on the number input by the user (significant digits).
You'll probably want to create your own custom NSFormatter subclass.
An NSFormatter converts strings entered by the user into objects (like
NSNumbers), and objects (like NSNumbers) into strings displayed to the
user.
So you could create your own custom NSFormatter that keeps track of
additional information like significant figures when doing the
string-to-object conversion, and allows the developer to set attributes
like whether to use exponential notation, how many significant figures
and decimal places to display, etc. for the object-to-string conversion.
I think it would be generally useful enough to others developing
scientific and engineering applications in Cocoa that it would make a
decent little Open Source project once you have a first pass that meets
your needs.
Oh, one other bit of advice: Use a unit testing framework like OCUnit
to do test-driven development of the formatter. It works *great* for
things like this.
-- Chris
--
Chris Hanson, bDistributed.com, Inc. | Email: email@hidden
Custom Mac OS X Development | Phone: +1-847-372-3955
http://bdistributed.com/ | Fax: +1-847-589-3738
http://bdistributed.com/Articles/ | Personal Email: email@hidden
_______________________________________________
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.