NSOrderedSets save the order of the objects in the table. If you access an NSManagedObject subclass instance with a property that is an NSOrderedSet, then they will be in order.
However, there is seemingly no way to access that order using an NSSortDescriptor when creating an NSFetchRequest.
It appears from the raw SQLite DB, that order is stored in fields named Z_FOK_<relationship name>
. The data is available, but it doesn't appear to be visible through the core data APIs.
Does anyone know a way to write an NSSortDescriptor that will work with a SQLite DB to return the results in the order specified by the NSOrderedSet?
Update
Related Question: NSFetchedResultsController and NSOrderedSet relationships
I don't think that is possible. The "ordering" is associated with the to-many relationship from one entity A
to another entity B
, it is not a property of the target entity B
.
But a sort descriptor for a Core Data fetch request can only use (persistent) properties of the entity.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With