我有一个SQLite支持的核心数据存储,希望使用NSFetchRequest
获取托管对象的列表。我希望上述列表按布尔值排序,该值可以在数据库级别轻松计算。我知道这一点是因为使用NSPredcate
可以制定相同的条件,如下所示:
[NSPredicate predicateWithFormat:@"uid = %@", currentUID]
遗憾的是,似乎没有办法使用NSSortDescriptor
来制定这样的条件。我该怎么做最好?我要拿两张单子吗,一张有
[NSPredicate predicateWithFormat:@"uid = %@", currentUID]
还有一个
[NSPredicate predicateWithFormat:@"uid != %@", currentUID]
and combine them later on? Can I then still elegantly use a NSFetchedResultsController
?
Or should I fetch all items and sort them later in code? Or is there anything I’ve missed.