I'm sorry I know this is basic swift, but how do I get I make the selection an optional return? I know it's with ?? ""
with a string, but I don't know how to do it with a date type.
Also how do I get a navigationBarTitle to work on this view? The "My Calendar" doesn't show up when I run the code.
import SwiftUI
struct ReciPrep: View {
@State private var date: Date? = ni
@Environment(\.calendar) var calendar
@State private var showingAddView = false
var body: some View {
VStack{
DatePicker("Calendar", selection: $date, in: Date.now...,displayedComponents: [.date]) //Error: Cannot convert value of type 'Binding<Date?>' to expected argument type 'Binding<Date>'
.datePickerStyle(.graphical)
Spacer()
}
.navigationBarTitle("My Calendar")
}
}
Any help would be greatly appreciated. Have a good day!