Re: Sorting an NSTableView by code
Re: Sorting an NSTableView by code
- Subject: Re: Sorting an NSTableView by code
- From: Matt Neuburg <email@hidden>
- Date: Thu, 29 Jun 2006 18:20:11 -0700
- Thread-topic: Sorting an NSTableView by code
On Fri, 30 Jun 2006 00:35:56 +0100, Drarok Ithaqua <email@hidden> said:
>I've tried the following (and variants similar to the following) to
>no avail:
>
> NSSortDescriptor* sorter = [[NSSortDescriptor alloc]
>initWithKey:@"tvcArtist" ascending:YES];
> [trackController setSortDescriptors:[NSArray arrayWithObject:sorter]];
You're doing it right. It is easy to confirm this with a tiny project
consisting of nothing more than this code:
- (void) awakeFromNib {
NSMutableArray* arr = [[NSMutableArray alloc] initWithCapacity: 3];
[arr addObject: [NSMutableDictionary dictionaryWithObject:@"Mannie"
forKey:@"tvcArtist"]];
[arr addObject: [NSMutableDictionary dictionaryWithObject:@"Moe"
forKey:@"tvcArtist"]];
[arr addObject: [NSMutableDictionary dictionaryWithObject:@"Jack"
forKey:@"tvcArtist"]];
[trackController setContent: arr];
}
- (void) doSort {
NSSortDescriptor* sorter = [[NSSortDescriptor alloc]
initWithKey:@"tvcArtist" ascending:YES];
[trackController setSortDescriptors:[NSArray arrayWithObject:sorter]];
}
This is always the way to track these things down. Try it on a minimal
project. If it works there and doesn't work in your real project, you must
be doing something in the real project to screw things up. Now all you have
to do is figure out what it is. :)
m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
_______________________________________________
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