• 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
Sorting a bound NSTableView programatically
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Sorting a bound NSTableView programatically


  • Subject: Sorting a bound NSTableView programatically
  • From: Jean-Nicolas Jolivet <email@hidden>
  • Date: Wed, 17 Dec 2008 21:53:12 -0500

I'm pretty sure this one is obvious but I'm just spinning around in circles in the docs here and I can't seem to find out how to do it...

I have a basic NSTableView binding setup in place (NSTableView's columns bound to an NSArrayController, which is bound to an NSMutableArray ...)

I'm trying to keep things simple so lets say my NSMutableArray is filled with custom "Person" objects that have only 2 properties: FirstName and LastName (the 2 columns of my NSTableView)...

Now, without doing anything (basically, just by setting my bindings correctly in IB) I can sort the 2 columns (FirstName and LastName) by clicking their headers, it works just fine (I'm guessing because "Create Sort Descriptors" is checked in IB)...

Now the thing is, the NSMutableArray is populated by an XML file that I am opening and parsing (again, no problems with that part)... I parse the XML file, which contains First names and Lastnames, create and add my "Person" objects to my array and the data is added to my NSTableView automatically....

What I need to do then, is to sort my tableview by FirstName automatically and then disable sorting altogether....

Basically, I am only opening XML files, the user is not allowed to add new rows/remove rows/etc. in the table, I only want to show the data, ordered alphabetically ....

Now I think I can "disable" sorting by unchecking "Create Sort Descriptors" in IB for my 2 columns, but I can't figure out how to sort my table view programatically...

(Also, while I'm on the subject, does sorting the NSArrayController's arrangedObjects also sorts the NSMutableArray to which my NSArrayController is bound to??)

Thanks,

Jean-Nicolas Jolivet
email@hidden
http://www.silverscripting.com

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Sorting a bound NSTableView programatically
      • From: Ken Thomases <email@hidden>
    • Re: Sorting a bound NSTableView programatically
      • From: Kiel Gillard <email@hidden>
  • Prev by Date: Re: Thread ID in crash log
  • Next by Date: Re: Sorting a bound NSTableView programatically
  • Previous by thread: Menu & System Preference keyboard shortcuts weirdness.
  • Next by thread: Re: Sorting a bound NSTableView programatically
  • Index(es):
    • Date
    • Thread