After updating Xcode to version 16, all functions that I used to create FetchDescriptor return with a warning:
Type ‘ReferenceWritableKeyPath<Station, Optional>’ does not
conform to the ‘Sendable’ protocol; this is an error in the Swift 6
language mode
Minimum example:
@Model public class Station {
var stationKey: Int16? = 0
}
extension Station {
static func allFD()->FetchDescriptor<Station> {
let predicate = #Predicate<Station> {value in
true
}
let descriptor=FetchDescriptor<Station>(predicate: predicate, sortBy: [SortDescriptor(Station.stationKey)])
return descriptor
}
The idea to have “FetchDescriptors” defined in an extension was to be able to use them both in Views and “background” code.
But now I am not sure how to proceed if I want to sort as well.
Thank you for your comments and ideas.