In the future, when you want to post code in these forums, it is best to wrap your code in triple backticks. (The button just below the escape key on your keyboard.) You can type 3 backticks on a line, press return twice, then type 3 more backticks. Then, paste your code on the line between the two lines of triple backticks.
This is one way that I just found to make this work.
Basically created a variable to store the number of people that the user is paying for...
@State private var payingFor = 1
Then, created a computed property to calculate the possible range of values that could be selected for that variable...
var payingForOptions: Range<Int> {
1..<numberOfPeople + 3
}
//This uses +3 because our number of people Picker position 0 is already offset by 2 people, and now we want our range to end with that same number of people.
//But ForEach won't accept a ClosedRange of Integers, so we have to end the range with <
Then, created a Picker
for it like this...
Picker("Paying for", selection: $payingFor) {
ForEach(payingForOptions, id: \.self) {
Text("\($0) people")
}
}