• 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 an NSTableView by code
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • RE: Sorting an NSTableView by code
      • From: "Drarok Ithaqua" <email@hidden>
  • Prev by Date: Re: NSScrollView - keep document view's top left pinned when resizing?
  • Next by Date: Re: Distributed Objects and Bonjour
  • Previous by thread: Sorting an NSTableView by code
  • Next by thread: RE: Sorting an NSTableView by code
  • Index(es):
    • Date
    • Thread