From what I see, in the .filter{}
method, filtering by just Date()
won't do.
See the example below,
let now = Date()
var delayedDate: Date!
// Causing a delay of 1 second
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
delayedDate = Date() // Date after one second
print("Date now:", now, ", Delayed date:", delayedDate!) // Printing the dates. See that they are not equal
print(now == delayedDate) // Checking if the dates are equal will result in false
}
This will result in the following

What this means that the date object you are comparing with the ones from CoreData is not equal. You can say that you are trying to equate COMPLETELY different objects.
So what you can do is, use a solution from this link to break a Date()
object into components such as date
, hour
, minute
, etc. and then compare the date
component with the ones from CoreData. Note that the component conversion needs to be done for the CoreData Dates as well