• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Sorting NSTableView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Re: Sorting NSTableView (From: "Joe Goh" <email@hidden>)
 >Re: Sorting NSTableView (From: "Joe Goh" <email@hidden>)
 >Re: Sorting NSTableView (From: Julio Cesar Silva dos Santos <email@hidden>)

  • Prev by Date: Re: [SOLVED] - MainMenu.nib - MyDocument.nib bindings question...
  • Next by Date: nibs, subclassing nsview
  • Previous by thread: Re: Sorting NSTableView
  • Next by thread: Get a value from NSTableView and put it in a NSString
  • Index(es):
    • Date
    • Thread