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?

Anoop Vaidya
  • 46,283
  • 15
  • 111
  • 140
Elendas
  • 733
  • 3
  • 8
  • 22
  • i have updated the question so that this question will be shown on Binding as well as ArrayController keywords – Anoop Vaidya Jan 10 '13 at 08:49
  • Please check this [project](http://www.keepandshare.com/doc/5462248/arraycontrollersortsearch-zip-58k?da=y)...which uses array controller and does searching and sorting. Without much codes, uses Bindings. – Anoop Vaidya Jan 10 '13 at 08:17

1 Answers1

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]];
Mennan
  • 4,451
  • 13
  • 54
  • 86
  • Maybe it works, but I'm lookin' for a solution with bindings instead of a predicate code solution, but thank you for your answer. – Elendas Jan 10 '13 at 08:38