let startDate: Date = Date()
let predicate = #Predicate<Trip> { session in
session.startTime >= startDate
}
Does anybody has this issue when #Predicate do not work on Date? I am getting unsupported predicate error. Any ideas to fix?
Since date isn't yet available to be used on the #Predicate macro, in the meantime, the following workaround can be used:
@Query private var queriedTrips: [Trip]
// Create a computed property
var trips: [Trip] {
let startDate: Date = Date()
return queriedTrips.filter({ $0.startTime >= startDate })
}
While this may not be ideal, I don't think there's much we can do at the moment.
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