Lawrence Gimenez

SwiftUI Journey Part 11: Passing parameters

Right now I am still figuring out how to pass a parameter from one View to another. I read I need to use @Binding but don’t know what it is. Or what differs it from @State. Currently, I am still studying @Binding.

All the tutorials and Apple documentation look good but they did not include what to do with the compile error in PreviewProvider.

Well, it seems PreviewProvider is separate and you can pass static variables different from the View class.

import SwiftUI

struct DetailsView: View {
    @Binding var url: String
    var body: some View {
        Text("Hello, World!")

struct DetailsView_Previews: PreviewProvider {
    @State static var urlPreview: String = Urls.main.advanceSearch
    static var previews: some View {
        DetailsView(url: $urlPreview)

Compiled successfully.