Created
February 6, 2024 20:59
-
-
Save christianselig/305d3362d83eaea4fecf214fb4054c9d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct ContentView: View { | |
var viewModel = CoolViewModel() | |
var body: some View { | |
VStack { | |
Menu { | |
Picker("Ice Cream", selection: $viewModel.selectedIceCream) { | |
ForEach(viewModel.iceCreams) { iceCream in | |
Text(iceCream) | |
.tag(iceCream) | |
} | |
} | |
} label: { | |
Text("Choose") | |
} | |
} | |
} | |
} | |
@Observable | |
class CoolViewModel { | |
var selectedIceCream = "chocolate" | |
var iceCreams: [String] = ["chocolate", "vanilla", "strawberry"] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment