Re: NSTableView column index
Re: NSTableView column index
- Subject: Re: NSTableView column index
- From: Mark Munz <email@hidden>
- Date: Sun, 30 Jan 2005 11:46:21 -0600
You have a few options that I can think of:
1. Store your data as an NSMutableArray of NSDictionary objects. The key for each dictionary would match the NSTableColumn identifier and return your data this way.
- (id)tableView:aTableView objectValueForTableColumn:aTableColumn row:rowIndex
{
return [[myArray objectAtIndex: rowIndex] objectForKey: [aTableColumn identifier]];
}
2. You could set the identifier to a number string, convert it to it's value and use that to index your record array
- (id)tableView:aTableView objectValueForTableColumn:aTableColumn row:rowIndex
{
int columnIndex = [[aTableColumn identifier] intValue];
return [[myArray objectAtIndex: rowIndex] objectAtIndex: columnIndex];
}
You could also map the column identifiers to your array indices. This would allow the user to re-arrange the columns visually, while the data underneath stayed in the same column order.
Mark Munz
On Jan 30, 2005, at 11:08 AM, Falko A. wrote:
Hi,
I'm trying to implement a sortable NSTableView, which is why I want to store the data of a multi column table
in one NSMutableArray. That array will contain sub-arrays containing the data for each column.
My data source has to know about the index of a column to return it's data.
Is there any way to query a column for its index/position in the tableView? Is there any other way to
sort a multi column table? I searched the internet, but I couldn't find any examples on sorting
an NSTableView with multiple columns...
I previously stored one array per column as its identifier, but there's probably no way to sort multiple
columns/arrays at once by an already existing function (where only one of the arrays is used to determine
the order), is there?
Thanks in advance
Falko A.
_______________________________________________
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