I cannot figure out how to sort a SwiftData query based on a boolean value. My sort works perfectly well for a string, date, int, etc. But crashes with a boolean.
@Query SortDescriptor with a Boolean
Hello,
I have not yet used SwiftData, but what init are you using for the SortDescriptor? I see this one in the documentation: [https://developer.apple.com/documentation/foundation/sortdescriptor/3802525-init)
init(
_ keyPath: KeyPath<Compared, Bool>,
order: SortOrder = .forward
) where Compared : NSObject
Is says that is needs to conform to NSObject. So might need to bridge it somehow so that the types are compatible. There is a way to do it via NSNumber.