• 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: NSTableView: programatically changing sorted column
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTableView: programatically changing sorted column


  • Subject: Re: NSTableView: programatically changing sorted column
  • From: Kyle Sluder <email@hidden>
  • Date: Mon, 5 Jul 2010 20:28:18 -0700

On Mon, Jul 5, 2010 at 7:36 PM, Graham Cox <email@hidden> wrote:
> I was hoping to avoid it because if I do that I have to duplicate the work that NSTableView does to maintain its list of sort descriptors. Since NSTableView already manages this list, it's easy to use.

I would argue that's less of a concern than inverting the
responsibilities of your controller and view layers. If "the sort
descriptors in use" is a concept that exists outside of the table
view, it really doesn't make sense to make the table view responsible
for maintaining it; that's the role of what the documentation would
term a "coordinating controller."

There are some places where views can be used on their own,
maintaining their entire state, or they can be used in conjunction
with a delegate or datasource that provides the state on demand. Yes,
that means the delegate or datasource has to reimplement some amount
of code the view already implements, but it's in the service of a
better design for the application developer and a more versatile view
class in the framework.

In fact, this situation comes up when adding bindings support to a
view. You'll wind up reimplementing a little bit of code the existing
non-bindings codepath will already have implemented (or will pass off
to its datasource), but you wind up with a view that can be bound or
used traditionally.

> I'd still like to know how a programmatic change to sort descriptors in a table view ought to be accomplished. It seems that the "highlighted" column really has logically nothing to do with the table's sort descriptors, even though when you interact with a table that's exactly what is used to indicate the sorted column. Weird.

I believe NSTableView is expecting you to take responsibility for
presenting it the sort descriptors in the right order. If you bind its
sortDescriptors binding to your controller, I would expect that
reordering and clicking on columns pushes the new sort descriptors
down the binding. So that's some built-in functionality that you don't
have to give up.

--Kyle Sluder
_______________________________________________

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: NSTableView: programatically changing sorted column
      • From: Graham Cox <email@hidden>
References: 
 >NSTableView: programatically changing sorted column (From: Graham Cox <email@hidden>)
 >Re: NSTableView: programatically changing sorted column (From: Kyle Sluder <email@hidden>)
 >Re: NSTableView: programatically changing sorted column (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: NSTableView: programatically changing sorted column
  • Next by Date: Re: Custom bundle icon
  • Previous by thread: Re: NSTableView: programatically changing sorted column
  • Next by thread: Re: NSTableView: programatically changing sorted column
  • Index(es):
    • Date
    • Thread