Re: Set NSTableColumn Arrow up/down
Re: Set NSTableColumn Arrow up/down
- Subject: Re: Set NSTableColumn Arrow up/down
- From: Jerry Krinock <email@hidden>
- Date: Fri, 02 Mar 2007 07:56:43 -0800
- Thread-topic: Set NSTableColumn Arrow up/down
I have no idea how you managed to get two arrows up there. But since you
asked for the "right way", I will give you my code. I don't know if it's
"right", but it does work:
- (void)tableView:(NSTableView *)tableView
didClickTableColumn:(NSTableColumn *)tableColumn {
NSString* key = [tableColumn identifier] ;
BOOL ascending ;
NSImage* currentImage = [tableView
indicatorImageInTableColumn:tableColumn] ;
if (currentImage == [NSImage imageNamed:@"NSAscendingSortIndicator"]) {
[tableView setIndicatorImage:[NSImage
imageNamed:@"NSDescendingSortIndicator"]
inTableColumn:tableColumn] ;
ascending = NO ;
} else {
[tableView setIndicatorImage:[NSImage
imageNamed:@"NSAscendingSortIndicator"]
inTableColumn:tableColumn] ;
ascending = YES ;
}
NSSortDescriptor* descriptor = [[NSSortDescriptor alloc] initWithKey:key
ascending:ascending
selector:@selector(localizedCaseInsensitiveCompare:)] ;
NSArray* descriptors = [NSArray arrayWithObject:descriptor] ;
NSArrayController* resultsController = [self resultsController] ;
[resultsController setSortDescriptors:descriptors] ;
[tableResults reloadData] ;
[tableResults selectRowIndexes:[[self resultsController]
selectionIndexes] byExtendingSelection:NO] ;
[descriptor release] ;
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden