Array with name and date in it

@Tito

OK that makes it much easier.

How were you going to create your list of check in Dates?

Before I was creating the checkIndate with a Picker with this code:
import SwiftUI

class ChangeViews: ObservableObject {
@Published var showAdd = false
@Published var dateSelection = “”
}

struct SettingsConfig: View {

@EnvironmentObject var changeViews: ChangeViews
@EnvironmentObject var listOfPeople: ListOfPeople


var body: some View {

    
    NavigationView {
        VStack {
            Toggle("Add Guest/ Delete Guest", isOn: $changeViews.showAdd)
                .font(.title2)
                .padding(20)
                .shadow(color: .gray, radius: 5)
            
            
           Picker("Select Guest List date", selection: $changeViews.dateSelection) {
                ForEach(listOfPeople.people, id: \.checkInDate) { person in
                    Text(person.checkInDate)
                        .tag(0)

                }
        
            }
            .pickerStyle(SegmentedPickerStyle())
            .cornerRadius(10)
            .font(.title2)
            .padding()
            .shadow(color: .green, radius: 60)
          .colorMultiply(.green)

But I get double checkIDates. I tried with the DatePicker but I get stuck.
DatePicker(“Select the checkin Date”, selection: $changeViews.dateSelection) {
ForEach(listOfPeople.people, id: .checkInDate) { person in
Text(person.checkInDate)
.tag(0)

                }
        
            }

The error that I got is: No exact matches in call to initializer

@Tito

Does the checkInDate have to be on specific dates or can it be any date whatsoever? At the moment it’s not clear.

Yes, it has to be on specific dates. The idea is to iterate through the checkInDates that are saved in the array listOfPeople. and show them in a Picker or better like you said in a DatePicker, and from that view to select an checkInDate and that checkInDate will show a list of people who are eligible to check in that day. The last part I was able to do it with a ForEach in a Picker but I got double dates in the view and is because there are 2 people on that same checkInDate (see picture below(. I need it to show only 1 checkInDate. I hope I answered the question and that I explained it well.

@Tito

OK so what you are saying is that you want your segmented Picker (or some kind of Picker) to show a list of dates to choose from that are extracted from the people array which contains those who have “checked in”. This kind of looks a bit like a player list where players indicate they are available on certain dates. Is that the case? Not that it matters what it’s for.

The sample data has the check in dates on either Thursday or a Friday. The point is that I assume that you want to be able to choose a date and see who is available on that date.

Yes correct. I have it almost working with help of you and @joash. Only the part that I got double checkInDates in my segmented Picker is the main issue now and I can’t find a solution for it now.

@Tito

A segmented picker is fine when you have only a few options to choose from. The problem is that things become cramped and text gets truncated when you have a lot of options as you can see in your example above. You are probably better off using a drop down picker (default) to choose the date that you want.

With regard to getting a unique set of dates to use in a Picker, I managed to put some code together in an App comprising the code that Joash posted and my own. Have a look at this and see if you can understand what I have done.

The dates used as test data are random just for the exercise. You will note that checkInDate is defined as type Date so this makes it easier to deal with overall.

Hi, Chris,

Can I get some answers from you, too?

What do you mean? Do you have a question? If so create a new question in the proper category

Chris,

Thnx I am going to look to it and I will let you know.

I asked a few a while ago, but I haven’t got any responses.

Comment on them again that you’re still looking for an answer and why solutions you tried!
The forum is sorted by date and when people ask a lot of questions at once, sometimes they can get kinda buried.

Please do comment and ask again! Our goal is to help you!