Replies: 1 comment
-
RealmSwift.SortDescriptor works fine |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
i update Realm version to 10.35.1 in app.
Previously, we used
NSPredicate
for filtering andNSSortDescriptor
for sorting objects. BothNSPredicate
andNSSortDescriptor
used structures like this#keyPath(Entity.id)
to define the field to filter or sort. In general, it looks like this:NSSortDescriptor(key: #keyPath(Entity.id), ascending: true)
orNSPredicate(format: "%K == %@", #keyPath(Entity.id), id)
.I know that it is possible to use the field name directly. For example:
NSSortDescriptor(key: "id", ascending: true)
. But our approach is used because the application is large and we would not like to look for errors at runtime if we forget to update some key after changing the name of the object field.Can you please tell me if it is still possible to use #keyPath for @persisted properties or maybe there is another approach for sorting?
NSSortDescriptor(keyPath \Entity.id, ascending: true)
initiator crashes with an errorBeta Was this translation helpful? Give feedback.
All reactions