• 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 with nstreecontroller
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sorting with nstreecontroller


  • Subject: Re: sorting with nstreecontroller
  • From: Philip Dow <email@hidden>
  • Date: Thu, 5 Jan 2006 09:27:15 +0100

Hi David,

What kind of objects are being added to the controller? If you can add another property to the object, something like "type," you could have the controller sort according to type first and then categoryName. Your default category type could be 1 and all the others 2 or something like that.

First, build an array of sort descriptors:

mySortArray = [[NSArray alloc] initWithObjects:
[[[NSSortDescriptor alloc] initWithKey:@"type" ascending:YES selector:@selector(compare:)] autorelease],
[[[NSSortDescriptor alloc] initWithKey:@"categoryName" ascending:YES selector:@selector(caseInsensitiveCompare:)] autorelease], nil];


Then have the controller sort according to that array:

[myTreeController setSortDescriptors:mySortArray];

Make sure your type property is kvo compliant and don't forget to release the array when finished!

-Phil


On Jan 5, 2006, at 8:03 AM, David Chan wrote:

Hi all,
I have an NSOutlineView that is using NSTreeController. It only
displays one field, categoryName.
Now it seems that the field is automatically sort-able alphabetically.
But there is one so-called "default category" which I would like to
always keep on top of the NSOutlineView while the other categoryNames
get sorted. How can I get this done? Thanks a lot.

Regards
David
 _______________________________________________
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


_______________________________________________ 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: 
 >sorting with nstreecontroller (From: David Chan <email@hidden>)

  • Prev by Date: Re: Checkboxes in Table Views
  • Next by Date: TextEdit's sheets curiosity
  • Previous by thread: sorting with nstreecontroller
  • Next by thread: Not getting filetype info from FSGetcatlogInfo() function
  • Index(es):
    • Date
    • Thread