I probably worked too much today..
In this tiny app when the button is clicked a new view must appear after 3 seconds hVideoURL variable is assigned a value (which is not NIL). So a new view (sheet) should appear with the text "IS NOT NIL"..
But for some reason when it's shown i see "wow, it's nil", which means variable still has no value.

Why i that? What am i missing?
struct ContentView: View {
@State var hVideoURL: URL? = nil
@State var isPaused: Bool = false
var body: some View {
Button("Let's Go!") {
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
print("settings isPaused to TRUE")
self.hVideoURL = URL(string: "https://firebasestorage.googleapis.com/v0/b/fitma-e3043.appspot.com/o/flamelink%2Fmedia%2F1-horizontal.mov?alt=media&token=8f7dfc0f-0261-4a78-9eb0-6154ce1d9dfe")
print("[debug] hVideoURL = \(hVideoURL)")
self.isPaused = true
}
}
.sheet(isPresented: self.$isPaused, onDismiss: {
self.isPaused = false
print("resume playing main video")
}) {
detailedVideoView
}
}
@ViewBuilder
var detailedVideoView: some View {
if self.hVideoURL != nil {
VStack {
Text("IS NOT NIL")
}
} else {
Text("wow, it's nil")
}
}
}