An Example: mTable = member instance for your TableView
mData = member array which provides the data-objects. Put the following code at a place where your table and data-source array is initialized. Like in awakeFromNib: method. Here I'm sorting on key "name", Change it to whatever key you have in your data-object on which you want to do the sorting. You can do the same thing from IB as well, then you don't have to write the following code. [mTable setSortDescriptors:[NSArray arrayWithObject: [[[NSSortDescriptor alloc]initWithKey:@"name" ascending:YES selector:@selector(caseInsensitiveCompare:) ]autorelease]]]; [mData sortUsingDescriptors:[mTable sortDescriptors]]; Now implement the following delegate for NSTableView: - (void)tableView: (NSTableView *)aTableView sortDescriptorsDidChange: (NSArray *)oldDescriptors { [mData sortUsingDescriptors: [aTableView sortDescriptors]]; [mTable reloadData]; } - Vijay On Fri, May 30, 2008 at 12:18 PM, James W. Walker <[EMAIL PROTECTED]> 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? > _______________________________________________ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > 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/vijay.malhan%40gmail.com > > This email sent to [EMAIL PROTECTED] > _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]