Re: Setting data cell type for a specific row
Re: Setting data cell type for a specific row
- Subject: Re: Setting data cell type for a specific row
- From: email@hidden
- Date: Tue, 27 Jan 2009 00:00:35 +0000 (UTC)
I. Savant:
> You don't get a reference to a cell. You tell the table view (via a
> delegate method) what prototype cell to use for the requested col/row.
> See:
> -[NSTableView tableView:dataCellForTableColumn:row:]
I took a look at that but it really seems to complicate things. Basically, I create the table and bind it to it's data source programatically. Once the table is bound and added to a view, the row count is known, so all I need to do is set that one cell.
I got part way there by doing:
// create an array controller
NSArrayController *controller = [[NSArrayController alloc] init];
[controller bind: @"contentArray" toObject: model withKeyPath: @"sites" options: nil ];
// create the table and bind the columns
[name bind: @"value" toObject: controller withKeyPath: @"arrangedObjects.name" options: nil ];
// get reference to the last cell in the desired column
int rowIndex = [[controller arrangedObjects] count] - 1 ;
id cell = [[table tableColumnWithIdentifier: @"delete" ] dataCellForRow: rowIndex];
[cell setImage: [PMImages addButtonOrange]];
[cell setAlternateImage: [PMImages addButtonWhite]];
[cell setAction: @selector (handleAdd:)];
Which works, only problem is, it changes the image and target for every cell in the column.
Is there no other way to do this other than ditching my table creation code completely and using a delegate? As above two lines indicate, this kind of thing should be trivial to do directly, provided there is some way to set the data cell.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden