Hi! I have an array with some parties information like date/place/day and time of the event in an array called events(eventos portuguese) and I want to iterate throught this array and check if the data of the event has passed today's date. This is the code I am using but for some reason that I don't know the forEach is not working:
func checkEventsDate() {
let dateFormatter = DateFormatter()
self.eventos.forEach { item in
guard let dt = dateFormatter.date(from: item.data) else { return }
if dt > Date() {
let index = self.eventos.firstIndex(of: item)
self.eventos.remove(at: index!)
} else {
print("maior")
}
}
}
what am I missing or what am I doing wrong? I dont get any error messages just the code doesnt work.
thank you very much