Thursday, May 19, 2022
HomeiOS Developmentios - @Binding date from one view to a different?

ios – @Binding date from one view to a different?


struct FirstView: View{
@State var MyDate = Date()
    var body: some View{
        Text("Hello world")
    }
}

struct  FirstView_Previews: PreviewProvider {
    static var previews: some View {
        FirstView()
    }
}



struct SecondView: View{
@Binding var MyDate: Date
@State var Thatdate = Date()
    var body: some View{
        Text("Hello world")
    }
}

struct  SecondView_Previews: PreviewProvider {
    static var previews: some View {
        SecondView(MyDate: <#Binding<Date>#>) <----- My problem is here
    }
}



struct ThirdView: View{
@Binding var MyDate: Date
@Binding var ThatDate: Date
    var body: some View{
      if Mydate == ThatDate{
      // do this 
        Text("Hello world")
    }
}

My question is how can i pass the binding date between views for comparing dates ? what is the binding date that should be instead of the shown above which is <#Binding#>, thank you for your help

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments