I have an array of object IDs and the array has the correct order.
let objectsIDs = [504, 316, 195, ...]
And I am using NSFetchedResultsController
with this NSPredicate
:
NSPredicate(format: "%K IN %@", #keyPath(object.id), objectsIDs)
NSFetchedResultsController
requires NSSortDescriptor
and I cannot use createdAt
or id
property to sort the objects.
How can I get NSSortDescriptor
to sort the objects based on the objectsIDs
array order? The objectsIDs
array always have the correct order and NSSortDescriptor
must depend on its order.