Is there any way to sort on key path to (or through) optional properties? I have this model:
struct ProcessFile : Codable
{
var id = UUID()
var label : String
var plistInfo : FileInfo
var executableInfo : FileInfo?
var executableExists : Bool { return self.executableInfo != nil }
}
struct FileInfo : Codable
{
var path : Path
var created : Date
var modified : Date
}
And I would like to enable SwiftUI TableColumn
sorting (via KeyPathComparator
) through the optional executableInfo
. I just want it to sort all the nil
values together either all greater than or all less than any non-nil value. Unfortunately, I get compiler errors (or timeouts trying to compile) on the TableColumn(…,value:)
using a key path through the optional executableInfo
. so even if I could handle the sort comparison manually, I don’t know how to enable this.