Picker not changing

hey y'all, how come this super simple code is not working for me? If I select a different unit in the Picker, it doesn't change its label
import SwiftUI

struct ContentView: View {

let unitList = ["Centimeters", "Meters", "Kilometers", "Inches", "Feet", "Yards", "Miles"]
@State private var unitDestination = "Meters"

var body: some View {
NavigationView {
Form {
Section {
Picker("Destinated Unit", selection: $unitDestination) {
ForEach(0..<unitList.count, id: \.self) { value in
Text(unitList[value])
}
}
}
}
}
}
}
import SwiftUI

struct ContentView: View {

let unitList = ["Centimeters", "Meters", "Kilometers", "Inches", "Feet", "Yards", "Miles"]
@State private var unitDestination = "Meters"

var body: some View {
NavigationView {
Form {
Section {
Picker("Destinated Unit", selection: $unitDestination) {
ForEach(0..<unitList.count, id: \.self) { value in
Text(unitList[value])
}
}
}
}
}
}
}
Solution:
changed it to ```swift Picker("Original Unit", selection: $unitOriginal) { ForEach(unitList, id: .self) { unit in Text(unit)...
Jump to solution
1 Reply
Solution
Pointer
Pointer15mo ago
changed it to
Picker("Original Unit", selection: $unitOriginal) {
ForEach(unitList, id: \.self) { unit in
Text(unit)
}
}
Picker("Original Unit", selection: $unitOriginal) {
ForEach(unitList, id: \.self) { unit in
Text(unit)
}
}
Want results from more Discord servers?
Add your server