I have an NSTableView that I am trying to sort. The data source is NSMutableArray, which contains instances of custom classes.
-(void)tableView:(NSTableView *)tableView sortDescriptorsDidChange: (NSArray *)oldDescriptors
I use the above to track when a user clicks on a table title. For sorting, I use the following method:
NSSortDescriptor *sortDescriptor; sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@"make" ascending:bool_asc_desc] autorelease]; NSArray *sortDescriptors = [NSArray arrayWithObject:sortDescriptor]; NSArray *sortedArray; sortedArray = [ads_printers_array sortedArrayUsingDescriptors:sortDescriptors];
What I would like to know is how can I pass in the column of the table that was clicked? This would allow me to modify initWithKey: @ "make" (using if statements) so that I can sort according to the header clicked.
Thanks.
PS I tried the following:
if ([ads_rdp_driver_table selectedColumn] == tc_make)
with ads_rdp_driver_table being my NSTableView and tc_make being the NSTableColumn that I defined. However, I get this error:
ISO C ++ prohibits comparison between pointer and integer
I think it might work if I can figure out the error.
Kevin source share