Helping with dropdown menu

This is my screen. Some worked and others didn’t


m

I think you need to re-check my last message. Your code doesn’t match mine.

You have upper case L on locationChoices
And you have two lines of ForEach instead of one lin eForEach and one line Text.

Here is my new screen. I copied everything exactly and got more errors

Unless there is another easier way I can do the picker

swap out you picker code for this:

Picker(“Please choose a Location”, selection: $location) {
ForEach(locationChoices, id: .self) {
Text($0)
}
}.pickerStyle(.segmented)
Text(“Current Selection: (location)”)

Still am getting errors

Try this code which should have the right double quotes you can copy:

Picker("Please choose a Location", selection: $location) {
    ForEach(locationChoices, id: \.self) {
        Text($0)
    }
}
.pickerStyle(.segmented)
Text("Current Selection: \(location)")

Yes, thank you! That worked

@rlong405

When you post code it needs to be formatted in a code block. After you paste the code in, select all of it and then tap the </> icon at the top of the message composing window to convert it into a code block.

Now that you have the right code, do you understand what that does?

Ah, apologies Chris, quite new here. Hadn’t realised it would throw characters out (I see it’s also removed my back slash.).

I’ll ensure I do that going forward.

Yes, if Im understanding it right, when the user shoes either worldwide or US which ever option that they want it will save it just for that one time to when I go to the next screen like a storage

I’m relatively new here too! We are all learning and growing though this process as we go along

I’m referring to the code itself rather than the result that the code provides, do you understand what each of the components in that section of code is doing the
Picker
ForEach
id
\.self
Text
$0

Understanding all of those elements is fundamental to understanding how the SwiftUI framework operates and understanding Swift syntax.

I understand most of them. I’m going back over the videos slowly but surely