Hi everyone.
I currently have a NSTableView set up, and it's data source is an instance of NSMutableArray called "logs". I have these data source methods implemented at the moment:
They all seem to work well enough as the data is loaded into the table correctly as you can see here:
However, when I click a column header, the data is not re-sorted based on that column. I have used the method in Hillegass' book, but it doesn't seem to work for me. If anyone could give me a hand it would be immensely helpful.
I currently have a NSTableView set up, and it's data source is an instance of NSMutableArray called "logs". I have these data source methods implemented at the moment:
Code:
- (id)tableView:(NSTableView *)aTableView
objectValueForTableColumn:(NSTableColumn *)aTableColumn
row:(int)rowIndex
{
NSString *identifier = [aTableColumn identifier];
Log *log = [logs objectAtIndex:rowIndex];
return [log valueForKey:identifier];
}
- (void)tableView:(NSTableView *)aTableView
setObjectValue:(id)anObject
forTableColumn:(NSTableColumn *)aTableColumn
row:(int)rowIndex
{
NSString *identifier = [aTableColumn identifier];
Log *log = [logs objectAtIndex:rowIndex];
[log setValue:anObject forKey:identifier];
}
- (void)tableView:(NSTableView *)aTableView
sortDescriptorsDidChange:(NSArray *)oldDescriptors
{
NSArray *newDescriptors = [tableView sortDescriptors];
[logs sortUsingDescriptors:newDescriptors];
[tableView reloadData];
}
They all seem to work well enough as the data is loaded into the table correctly as you can see here:
However, when I click a column header, the data is not re-sorted based on that column. I have used the method in Hillegass' book, but it doesn't seem to work for me. If anyone could give me a hand it would be immensely helpful.