title: SwiftUI Question passing a variable to another view
body: <p>I am wanting to pass a Float Variable from one view to another new view.</p>
  
  <p>In the code below there is a Float value called mhzValue which is set by way of the Slider, the slider changes the value and Text is then displaying within the view.. When the user taps on the Navigation Button to display the new view, I would like to be able to take the mhzValue and display it in the new view in a text box, as well as set it as another variable.</p>
  
  <p>Hope that makes sense.</p>
  
  <p>Please see some sample code below..</p>
  
  <p>Thank you.</p>
  
  <p>Craig</p>
  
  <pre><code>import SwiftUI
  struct ContentView : View {
      @State private var mhzValue : Float = 0
      var body: some View {
          // Navigation View
          NavigationView {
  
              VStack{
                  Text("Test Value:")
                      .font(.headline)
                      .color(.blue)
                      .padding(.leading, -180.0)
  
                  //Get Slider Value
                  Slider(value: $mhzValue, from: 1, through: 55, by: 1)
                      .padding(.horizontal)
                  //Display Slider Value
                  Text("\(Int(mhzValue)) Value")
                      .font(.title)
                      .fontWeight(.semibold)
                      .color(.blue)
                  // Naviagtion Button and send value of mhzValue to new View
                  NavigationButton(destination: NextView()){
                      Image(systemName: "plus.square.fill")
                          .foregroundColor(.white)
                          .font(/*@START_MENU_TOKEN@*/.title/*@END_MENU_TOKEN@*/)
                          .frame(width: 150.0, height: 16.0)
                          .padding(15)
                          .background(Color.red)
                          .cornerRadius(10.0)
                  }
              }
          }
      }
  }
  
  // New View to show Slider Value
  struct NextView : View {
      var body: some View {
          Text("Display Slider Value Here:")
  
      }
  }
  
  #if DEBUG
  struct ContentView_Previews : PreviewProvider {
      static var previews: some View {
          ContentView()
      }
  }
  #endif
  </code></pre>