• 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: email@hidden
  • Date: Fri, 22 Feb 2002 16:02:13 -0800

Um... nobody has done anything about it because it's not regarded as a bug, would be my guess. :-> Modularity of design is good. If you want your value formatted, use an NSFormatter. If you want a cheaper solution, use setStringValue: and format the string yourself. But building in code in NSTextfield that lets you set things like the precision, the exponent format, etc. would be an exceedingly bad design, IMHO.

This is how I would implement it:

Define a shared number formatter for all text fields. That will work for, say, 90% of the cases, if not more. Then I wouldn't have to create all sorts of little number formatters (big waste of memory).

You can use one formatter and share it among all the fields that want it. In fact, this is how you're *supposed* to do it. It's not Cocoa's fault that you're using it incorrectly.

For the rare case make me drag a NSNumberFormatter from IB palette to the text field.

That solution would also save on my wrist as I drag out hundreds of formatters for no reason at all besides the fact that the default behavior is useless.

You just don't understand the way it's designed. There is no reason for you to be dragging out hundreds of formatters.

I haven't looked into this problem in years because we make our own formatters, so maybe something has changed and I can enable a default behavior after all. If that is the case I'd like to know it.

Subclass NSTextfield, in your subclass init method add your shared formatter object, in IB create instances of your subclass. Nothing could be easier. Alternatively, you could attach your shared formatter in code after your nib loads, or even have your subclass of NSTextfield pose as NSTextfield so you get this behavior with no modification (although I wouldn't recommend that).
What *you* think is good default behavior is not what another person would think is good default behavior. (I, for example, don't want the default behavior you suggest; I don't want the default behavior to be making assumptions about what precision I consider significant). That is why Cocoa makes no particular effort to define a sophisticated default behavior, but instead is designed to be easily customized with formatters.
It doesn't bother me that you don't understand Cocoa's design; none of us on the list know everything. But it does bother me that you assume the design is broken, and insult the designers, without educating yourself about it first.

Ben Haller
Stick Software
_______________________________________________
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.

  • Follow-Ups:
    • Re: number formatting
      • From: "Jonathan W. Hendry" <email@hidden>
References: 
 >Re: number formatting (From: Lance Bland <email@hidden>)

  • Prev by Date: Re: +poseAsClass and instance variables
  • Next by Date: NSView subclass input question
  • Previous by thread: Re: number formatting
  • Next by thread: Re: number formatting
  • Index(es):
    • Date
    • Thread