Re: Sorting NSTableView
Re: Sorting NSTableView
- Subject: Re: Sorting NSTableView
- From: "Joe Goh" <email@hidden>
- Date: Thu, 24 Aug 2006 09:31:51 +0800
On 8/23/06, Julio Cesar Silva dos Santos <email@hidden> wrote:
Just for the records, post the solution too! Can you figure out a
newbie following this thread and finding out that you just 'got it'?
Very frustrating...
True true, so for the sake of the other Cocoa newbies out there...
I fixed the problem by not subclassing NSTableView, but instead
subclassing NSObject (let's call it AppController) and connecting an
outlet from the instance of AppController to the NSTableView. So this
code, doesn't work...
@implementation ContactView
- (void) awakeFromNib
{
NSSortDescriptor* sortDescriptor = [[[NSSortDescriptor alloc]
initWithKey: @"name" ascending: YES] autorelease];
[self setSortDescriptors:[NSArray arrayWithObject:sortDescriptor]];
[self reloadData]; // Is this needed?
}
@end
But instead, this works flawlessly,
@implementation AppController
- (void) awakeFromNib
{
NSSortDescriptor* sortDescriptor = [[[NSSortDescriptor alloc]
initWithKey: @"name" ascending: YES] autorelease];
[contactView setSortDescriptors:[NSArray arrayWithObject:sortDescriptor]];
}
@end
Hope this helps someone out there,
Joe
_______________________________________________
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