Sorting one column table?
Sorting one column table?
- Subject: Sorting one column table?
- From: Bob Ueland <email@hidden>
- Date: Tue, 2 Oct 2007 14:56:51 -0500 (CDT)
I'm testing sorting a table using datasource. When I did it with a table with two columns all went well. I was using
- (void)tableView:(NSTableView *)aTableView
sortDescriptorsDidChange:(NSArray *)oldDescriptors
{
NSArray *newDescriptors = [aTableView sortDescriptors];
[books sortUsingDescriptors:newDescriptors];
[aTableView reloadData];
}
However when I tried with a table consisting of one column I got following error message
[<NSCFString 0x2d00c> valueForUndefinedKey:]: this class is not key value coding-compliant for the key title.
When I used two columns I had a mutable array books, consisting of book objects, where a book object consisted of a title and an author. So I had key value coding-compliant getters and setters for them.
However for one column table there is no need to have a special Book class, since each book is identified by its title only. So my mutable array consists of NSStrings where each string is a title of a book. So there is no need to have setters and getters. And that seems to prevent sorting using the tableView:sortDescriptorsDidChange: method.
So my question is, how do I introduce sorting for one column table.
Bob
____________________________________________________________________________________
Shape Yahoo! in your own image. Join our Network Research Panel today! http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7
_______________________________________________
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