Re: Re: Sorting NSTableView
Re: Re: Sorting NSTableView
- Subject: Re: Re: Sorting NSTableView
- From: malcom <email@hidden>
- Date: Sat, 29 Jul 2006 15:30:26 +0200
Damn this is a wonderful thread!
Ok I've found the solution. This is the method used when user click on
outlineview header:
- (void)outlineView:(NSOutlineView *)outlineView
mouseDownInHeaderOfTableColumn:(NSTableColumn *)tableColumn {
if (lastColumn == tableColumn) {
// User clicked same column, change sort order
sortDescending = !sortDescending;
} else {
// User clicked new column, change old/new column headers,
// save new sorting selector, and re-sort the array.
sortDescending = NO;
if (lastColumn) {
[self setIndicatorImage: nil
inTableColumn: lastColumn];
}
}
lastColumn = [tableColumn retain];
[self setHighlightedTableColumn: tableColumn];
[listOfMsg sortUsingSelector: [[tableColumn sortDescriptorPrototype]
selector]];
if (sortDescending) [self reverse: listOfMsg];
[self reloadData];
}
- (void)reverse:(NSMutableArray *) _list {
int i;
for (i=0; i<(floor([_list count]/2.0)); i++) {
[_list exchangeObjectAtIndex:i withObjectAtIndex:([_list count]-(i+1))];
}
}
_______________________________________________
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