• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Number Formatting
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Number Formatting (From: Daniel Todd Currie <email@hidden>)

  • Prev by Date: Formats supported by NSImage?
  • Next by Date: Re: Formats supported by NSImage?
  • Previous by thread: Number Formatting
  • Next by thread: Formats supported by NSImage?
  • Index(es):
    • Date
    • Thread