Re: Applying an NSNumberFormatter to an NSTableColumn
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.