I'm working on a project that will need to do calculations based on the user's age.
I'm wanting to start completely with SwiftUI and I can do the graphical stuff but I'm at a loss as to how to use that information.
So the standard code I have is this:
struct ContentView: View {
@State private var birthDate = Date()
var body: some View{
Form {
DatePicker("Birth date:", selection: $birthDate, in: ...Date(), displayedComponents: .date).datePickerStyle(WheelDatePickerStyle()).font(.title)
}
}
}
What I'm having trouble with is how do I take the information from the date picker to then calculate the age of the user to store in a variable for later calculations?
Thanks so much for any help you can provide.