On Thu, 27 Jul 2006 23:37:43 -0500, Zef RosnBrick
<email@hidden>
said:
Is there any way to programmatically create every you need for a
table column except for dragging the table column into a window in
IB, setting the number of columns to zero, and making the connection?
Basically, I want to create multiple columns for my table view, and
populate them from an array or dictionary. Some sample code would be
great.
Some of the most important words from your question seem to have been
swallowed by the cookie monster, so it isn't entirely clear what
you're
asking. But it looks like you're asking how to create a table
column in
code. The answer is: you do it the same as you create anything else in
Cocoa, namely with alloc and the designated initializer. So:
NSTableColumn* tc = [[NSTableColumn alloc]
initWithIdentifier:@"whatever"];
[theTable addTableColumn:tc];
[tc release];
That's it. If there are other aspects of the table column you wish
to set,
such as its header cell string, width, editability, movability,
etc., go
right ahead; RTFM on NSTableColumn to see what sorts of things you
can do.
The last thing you ask about is how to "populate" the table column.
But
tables and columns don't contain data in Cocoa (data sources do),
so there
is nothing to populate. If you want the table column bound, bind it
(with
bind:...). Or, if using an old fashioned data source (as in
NSTableDataSource), there is nothing to do, since your data source
will be
asked the correct Three Big Questions automatically (this is what the
identifier is for).
m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>