How to display sort indicator in the table header?

1.3k views Asked by At

I sorted the NSTableColumn using the sort descriptors. I used the following code for Sorting.

 NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"Column3" ascending:NO];
        NSArray *sortDescriptors= [NSArray arrayWithObject:sortDescriptor];
        [self.dataArray sortUsingDescriptors:sortDescriptors];

[tableView setIndicatorImage:[NSImage imageNamed:@"NSAscendingSortIndicator"]
                          inTableColumn:[tableView tableColumnWithIdentifier:@"Column3"]]; 

I am able to get the image from [NSImage imageNamed:@"NSAscendingSortIndicator"],but Iam not able to view the image in the tableview header.

Is there any way to simulate the mouse click on the table column to get that Sort indicator(up or down arrow in the table header) in the table column.

1

There are 1 answers

0
Ram On BEST ANSWER

Following Code will update the Sort indicator with out clicking on the header.

[self.tableView setSortDescriptors:sortDescriptors];