• 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: Appropriate Use of NSFormatter?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Appropriate Use of NSFormatter?


  • Subject: Re: Appropriate Use of NSFormatter?
  • From: Keary Suska <email@hidden>
  • Date: Sun, 29 Nov 2009 13:55:03 -0700

On Nov 29, 2009, at 1:44 PM, Jericho Hasselbush wrote:

> I've been considering the best way to integrate user's choice of units in my app (metric and standard) and have yet to figure out a clean way of doing it.
>
> I am considering using a custom formatter that will change it's behavior based on a globally accessible variable holding the type of system - probably in the App Delegate, since the app will store the data in the same units no matter what. The respective controllers can watch the keyValue of the app delegate and update their respective views when the App Delegate's variable changes.
>
> Is this an acceptable use of a custom formatter, or am I making this harder than necessary?

Probably better to use an NSValueTransformer, which gives you reverse transformation as well. If you are using bindings you get this (forward & reverse transforms) for free.

You will probably still want a formatter, if just to show the correct suffix (e.g. "in" vs "cm").

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

_______________________________________________

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

  • Follow-Ups:
    • Re: Appropriate Use of NSFormatter?
      • From: Alastair Houghton <email@hidden>
References: 
 >Appropriate Use of NSFormatter? (From: Jericho Hasselbush <email@hidden>)

  • Prev by Date: Appropriate Use of NSFormatter?
  • Next by Date: Re: Appropriate Use of NSFormatter?
  • Previous by thread: Appropriate Use of NSFormatter?
  • Next by thread: Re: Appropriate Use of NSFormatter?
  • Index(es):
    • Date
    • Thread