我有NSScrollView
与ArrayController
绑定。我需要按字母顺序对内容进行排序。我试图用绑定做到这一点,但我找不到合适的东西来绑定。我在sortDescriptor
上使用了以下ArrayController
。
[myArrayController setSortDescriptors:[NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"myKey" ascending:YES selector:@selector(compare:)]]];
我是否会错过这个过程中的一个步骤,或者我甚至不接近对内容进行排序?
答案 0 :(得分: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]];