i have an array and inside of it List type of objects
struct List:Decodable {
let dt: Int //1593183600
let dateTime: String //2020-06-26 15:00:00
}
i want to filter the array if object dt is already in array.
examle:
dt: 1593183600,//2020-06-26 21:00:00 dt: 1593216000// 2020-06-27 00:00:00 dt: 1593226800//2020-06-27 03:00:00
the array should not contain 2020-06-27 . it does not matter which one should be remove
my main purplose is writing the weekdays according to time interval values. any diffirent idea would be great
according to your link i tried it like that
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd"
//var filteredDays: [List] = []
let unique = data.unique{formatter.date(from: $0.dateTime)}
print(data.count)//40
print(unique.count) //1
it should return 5 days but return one