I have this code for presenting a SafariView
struct ContentView: View {
@ObservedObject var viewModel: ContentViewModel
@State var url: URL?
@State var toShowSafari: Bool = false
var body: some View {
VStack {
Button(action: {
url = URL(string: "https://www.google.com")
toShowSafari = true
}, label: {
Text("Tap me")
}).fullScreenCover(isPresented: $toShowSafari) {
let _ = print("url - \(url)")
if let url = url {
SafariView(url: url)
}
}
}
}
}
Why the result of the print here is "url - nil" and how can I make those changes be executed in order?