0

我有一个NSScrollViewArrayController. 我需要按字母顺序对内容进行排序。我试图用绑定来做到这一点,但我找不到合适的东西来绑定。我sortDescriptor在我的ArrayController.

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

我是否错过了流程中的一个步骤,或者我什至没有接近对内容进行排序?

4

1 回答 1

0

你试过 FilterPredicate 吗?这是一个示例代码:

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]];
于 2013-01-10T08:25:20.243 回答