littleDrummerBoy
littleDrummerBoy

Reputation: 157

Sorting multiple NSArraycontroller and multiple NSTables using bindings

I have multiple NSTables, with Multiple NSArraycontrollers tied into CoreData. I successfully have one table sorting. When I apply the same settings to any other NSTable (Column) and NSArraycontroller it will not work.

In the Column, I have the Sort Key, Selector and Order set.

In NSArraycontroller, I have Sort Descriptors set as follows:

Binds to: Shared User Defaults Controllers

Controller Key: values

Model key path: sortDescriptors

Value transformer: NSUnarchiveFromData

If I apply the same settings to one of the other NSArraycontrollers, I get an error. "The entity ?? is not key value coding-compliant for the key "??".

Any thoughts?

EDIT: Just realized, in the error, the "...coding-compliant for the key 'xx'." This key is the Sort Key for the first column and it appears in the error message for all the other NSArraycontrollers. Not sure why that is. I've set the Sort Keys in the other correctly, so why would it be looking at the first one I setup?

Upvotes: 1

Views: 83

Answers (1)

littleDrummerBoy
littleDrummerBoy

Reputation: 157

Not sure why the bindings were not working, but to solve my sorting problem I created an NSSortDescriptor for each of the NSArrayControllers in the awakeFromNib method and everything is sorting.

-(void)awakeFromNib {
    NSSortDescriptor *nameSort = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES];
    [nameArrayController setSortDescriptors:[NSArray arrayWithObject:nameSort]];
}

Upvotes: 1

Related Questions