Re: NSTableView - Programmatically creating Table Columns and populating
Re: NSTableView - Programmatically creating Table Columns and populating
- Subject: Re: NSTableView - Programmatically creating Table Columns and populating
- From: Zef RosnBrick <email@hidden>
- Date: Sat, 29 Jul 2006 00:34:33 -0500
I finally got my table view working, but now if wont respond to
[myTableView selectedColumn] or selectedRow - it always returns 0. It
also doesn't return anything for number of table columns.
Zef
On Jul 28, 2006, at 7:56 AM, Matt Neuburg wrote:
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>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden