是否无法使用NSSortDescriptor按BOOL属性排序?

时间:2013-07-30 20:11:58

标签: ios objective-c sorting core-data nssortdescriptor

我需要从fetchedResultsController

对我的部分中的行进行排序

我正在尝试确保将lastCell属性设置为YES的实体成为其中最后一个显示的单元格。不知何故,它始终是第一个?这不可能吗?

从timeStamp订购效果很好。另一方面lastCell似乎没有任何影响。

NSSortDescriptor *sortDescriptor1 = [[NSSortDescriptor alloc] initWithKey:@"timeStamp" ascending:NO];
NSSortDescriptor *sortDescriptor2 = [[NSSortDescriptor alloc] initWithKey:@"lastCell"  ascending:NO];

2 个答案:

答案 0 :(得分:5)

将lastCell的NSSortDescriptor设置为升序。毕竟,False(又名0)出现在True(1)之前。

答案 1 :(得分:0)

您可能会尝试创建一个简单的自定义比较方法来使用。这个问题对此很好:

Very custom order using NSSortDescriptor