Sorting an NSTableView bound to an NSArrayController.
Sorting an NSTableView bound to an NSArrayController.
- Subject: Sorting an NSTableView bound to an NSArrayController.
- From: Robert Tillyard <email@hidden>
- Date: Thu, 28 Jun 2012 16:44:17 +0100
Hello,
I'm writing an application that handles results for a running club.
I have an NSTableView that has columns bound to a CoreData Entity such as Entries.arrangedObjects.position, position is an NSString that contains numbers such as @"1" and @"2" or @"" but the position can also be @"DNF" (Did not finish).
I have a method in the WindowController that sorts the 'Entry' objects and handles these cases correctly returning an NSArray using:
[array sortUsingComparator:^(id obj1, id obj2)
{
NSComparisonResult r;
r = ....
return (r);
}];
How can I get my table view to work so that when the user clicks in the Pos. column I can do my custom sort? at present it is doing an ASCII sort so I get 1, 10, 100, then 2, 20, 200 etc...
I now I need to put a key and sort descriptor in IB but don't know what code I have to add to the Entity ot WindowController to handle it.
Thanks, regards, Rob.
_______________________________________________
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