Saving the User Selection on a Picker After Pressing a Button


struct picker: View {
var cardCarriers = [“Chase”, “Citibank”, “Capitol One”, “Wells Fargo”, “Bank of America”]
@State var pickerSelectedItem = 0

var body: some View {
    VStack {
    Picker(selection: $pickerSelectedItem, label: Text("")) {
        ForEach(0 ..< cardCarriers.count) { index in
        Text("Selected Card carrier: \(cardCarriers[pickerSelectedItem])")

How do you add the button that saves the user data

Hey @Kelvin_Jou,

Not entirely sure what you mean, but if you are looking to store a value for a user even after the app has been closed/through multiple sessions, try using User Defaults. Check this video out: