Post

Replies

Boosts

Views

Activity

Iterate over an array and delete events that is older than present's day.
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
2
0
385
Nov ’23
Iterate over an array and delete events that is older than present's day.
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
Replies
2
Boosts
0
Views
385
Activity
Nov ’23
Can not test my app on my device because of version compatibility.
Hi! I have a Mid 2015 Macbook running XCode 14.2 and an iPhone 11 Pro with iOS 17.1. How can I deploy my app to app store if I can not run a test on my device since it is running iOS 17.1 and my xcode does not have iOS 17 framework because my macbook is old enough to have it? thank you
Replies
1
Boosts
0
Views
843
Activity
Nov ’23