I have a SQLite-enabled data warehouse and want to get a list of managed objects with NSFetchRequest. I want the specified list to be sorted by a boolean value that can be easily calculated at the database level. I know this because the same conditions can be formulated using NSPredicatewhich would look like this:
[NSPredicate predicateWithFormat:@"uid = %@", currentUID]
Unfortunately, it seems that there is no way to formulate such a condition using NSSortDescriptor. How am I best to do this? Do I get two lists, one with
[NSPredicate predicateWithFormat:@"uid = %@", currentUID]
and one with
[NSPredicate predicateWithFormat:@"uid != %@", currentUID]
and combine them later? Can I still use it elegantly NSFetchedResultsController?
Or should I get all the elements and sort them later in the code? Or I didn’t miss anything.
source
share