Sort the contents of an NSScrollView, NSTableView, using Binding in ArrayController
Asked Answered
T

1

0

I have an NSScrollView wich is bound with an ArrayController. I need to sort the content alphabetically. I've tried to do this with bindings but I can't find the right thing to bind. I used the following sortDescriptor on my ArrayController.

[myArrayController setSortDescriptors:[NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"myKey" ascending:YES selector:@selector(compare:)]]];

Do I miss a step in the process or am I not even close to sorting the content?

Tube answered 10/1, 2013 at 8:13 Comment(2)
Please check this project...which uses array controller and does searching and sorting. Without much codes, uses Bindings.Teevens
i have updated the question so that this question will be shown on Binding as well as ArrayController keywordsTeevens
C
0

Did you try FilterPredicate ? this is a sample code:

NSDate *afterDate=[balanceDateAfter objectValue];
NSDate *beforeDate=[balanceDateBefore  objectValue];
NSComparisonResult duration=[beforeDate timeIntervalSinceDate:afterDate];

duration=duration/3600;
duration=duration/24;

[checkInBalanceArray setFilterPredicate:[NSPredicate predicateWithFormat:@"(checkDate >= %@) AND (checkDate <= %@)", afterDate, beforeDate]];

[checkOutBalanceArray setFilterPredicate:[NSPredicate predicateWithFormat:@"(checkDate >= %@) AND (checkDate <= %@)", afterDate, beforeDate]];
Cambium answered 10/1, 2013 at 8:25 Comment(1)
Maybe it works, but I'm lookin' for a solution with bindings instead of a predicate code solution, but thank you for your answer.Tube

© 2022 - 2024 — McMap. All rights reserved.