Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sorting an NSTableView




On May 30, 2008, at 12:48 AM, James W. Walker wrote:

Hi. I'm a Cocoa newbie, and I'm trying to figure out how to enable sorting columns of my table, but the NSTableView guide doesn't say anything about it. I see that NSTableView has a setSortDescriptors method, NSTableColumn has a setSortDescriptorPrototype method, and that IB shows a "sort key" attribute for a table column, but I'm not clear on how to use them. Any hints or examples?

I'm sure Vijay's solution is more correct than mine, but I implement the

-(void)tableView:(NSTableView *)tableView didClickTableColumn: (NSTableColumn *)tableColumn

delegate method and highlight the column header myself (reversing the sort as necessary and setting the right sort direction indicator). Then I sort my data source and call reloadData on the table object.

I found this MacTech article useful for getting to know NSTableView a little better also:

<http://www.mactech.com/articles/mactech/Vol.18/18.09/TableTechniques/index.html >

Ken

--
Ken Worley
Software Engineer, Tiberius, Inc.



_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >sorting an NSTableView (From: "James W. Walker" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.