Well, I'll make extra effort to help, but it would be much better for you to try, fail, retry and get it.You would learn much more.
I did not test the code below, so there may be some points to correct. In addition, is not specifically written for SwiftUI syntax.
// get startDate
let repeats = 2
let startDate = Date() // Change with what you get from the picker
// get endDate
let endDate = Date() // Change with the second date you get from picker
var repeatArray : [Date] = []
var runningDate = startDate
let calendar = Calendar.current
let dateComponents = calendar.dateComponents(
[.calendar, .timeZone, .year, .month, .day], from: runningDate)
// The repeat loop
while runningDate = endDate {
repeatArray.append(runningDate)
// add increment to runningDate
switch repeats {
case 1 : runningDate = calendar.date(byAdding: .day, value: 1, to: runningDate)! // ?? endDate
case 2 : runningDate = calendar.date(byAdding: .day, value: 7, to: runningDate)!
case 3 : runningDate = calendar.date(byAdding: .month, value: 1, to: runningDate)! // you increment the month
default: break
}
}
Now, it is up to you to fine tune this. Wish you best.
And don't forget to close the thread.