• 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: Applying an NSNumberFormatter to an NSTableColumn
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Applying an NSNumberFormatter to an NSTableColumn


  • Subject: Re: Applying an NSNumberFormatter to an NSTableColumn
  • From: Boaz Stuller <email@hidden>
  • Date: Sat, 5 Jul 2003 16:29:43 -0400

It's the dataCell you need to set the formatter for, not the headerCell. But the real problem is that you're working way too hard and making you code inflexible to boot. You can add a formatter to a table column in interface builder just by dragging it onto the column's header region, and then setting it up in the info panel for that column (it'll add a new entry to the pop up menu in the info panel called Formatter). If you have to set it programmatically, you'll have better luck looking up you column by identifier rather than index; that way if your table gets reordered, your code will still work.

Bo

On Saturday, July 5, 2003, at 04:01 PM, Paul N. Schatz wrote:

I read some doubles into a table and wish to format the fourth column with dollar signs and commas.

I use the following code:

NSNumberFormatter *numberFormatter =
[[[NSNumberFormatter alloc] init] autorelease];
[numberFormatter setFormat:@"$#,##0.00"];
[[[[tableView tableColumns] objectAtIndex:3] headerCell] setFormatter:numberFormatter];
[tableView reloadData];

This compiles and runs but has no effect whether run before or after the numbers are entered into the table.

Where am I going wrong?

Paul
--
--
Paul Schatz
Chem Dept
University of Virginia
_______________________________________________
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.
_______________________________________________
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: 
 >Applying an NSNumberFormatter to an NSTableColumn (From: "Paul N. Schatz" <email@hidden>)

  • Prev by Date: Applying an NSNumberFormatter to an NSTableColumn
  • Next by Date: ScreenSaverView and subviews
  • Previous by thread: Applying an NSNumberFormatter to an NSTableColumn
  • Next by thread: ScreenSaverView and subviews
  • Index(es):
    • Date
    • Thread