• 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
Fwd: Textfields, formatters, localize and using binding.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fwd: Textfields, formatters, localize and using binding.


  • Subject: Fwd: Textfields, formatters, localize and using binding.
  • From: Joakim Danielson <email@hidden>
  • Date: Mon, 17 May 2004 12:08:11 +0200

I've just realized something:

When testing this yesterday, I tried to uncheck the box "Add 1000
Separators" in IB, but it didn't work.
Today I tried to do the same thing in the code and that works! Altough
I would prefer to have a thousand separator for readability.

Here's the code in awakeFromNib:

NSNumberFormatter *numberFormatter = [[[NSNumberFormatter alloc] init]
autorelease];
[numberFormatter setFormat:@"#,###.00;0.00;($#,##0.00)"];
[numberFormatter setLocalizesFormat:YES];
[numberFormatter setHasThousandSeparators:NO];
[volumeField setFormatter:numberFormatter];
[amountField setFormatter:numberFormatter];
...

Joakim

Begin forwarded message:

> From: Joakim Danielson <email@hidden>
> Date: 17 maj 2004 11.56.59 MET
> To: email@hidden
> Subject: Textfields, formatters, localize and using binding.
>
> Hi
>
> I've run into a problem I can't find a good solution to. Here is the
> situation:
>
> I have created a GUI to to register and store transactions (for a
> stock portfolio program). The GUI is very simple with some
> popup-buttons, text fields and buttons.
> The popup-buttons and the text fields are all bound to a
> NSObjectController. Four of the text fields contains numbers so I've
> attached a formatter to them and here is where my troubles start.
>
> Since I'm Swedish I want to localize the fields so that the double
> 1000.99 is written as "1 000,99". For bound text fields formatting
> only works as long as the value is less than 1000, any larger value
> will generate a call to setNilValueForKey, that is any value
> containing a thousand separator!
>
> Is this a bug or do I have to use formatters in a different way for
> bound fields?
>
> I have tried to create and set the formatter in the code instead of IB
> but the result is the same. I should also mention that in my model
> class the responding attributes are doubles. I tried to change one to
> NSNumber but again, the result was the same.
>
> Joakim
_______________________________________________
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.


  • Prev by Date: Re: Recuperating after NS_HANDLER
  • Next by Date: Re: Hiding NSTableColumns?
  • Previous by thread: Textfields, formatters, localize and using binding.
  • Next by thread: Hiding NSTableColumns?
  • Index(es):
    • Date
    • Thread