I've been trying to implement the example used in the WWDC session 226 - "Data flow through SwiftUI"and seem to be having a problem that doesn't correspond to the examples shown in the Video...
I get the error:
ContentView.swift:21:13: 'PlayButton.Type' is not convertible to '(Binding<Bool>) -> PlayButton'
The funny thing is it worked at first but stopped working spontaneously..
Any help solving this or even just confirmation it is (or isn't) a common problem is appreciated.
Here's my ContentView.Swift :
import SwiftUI
struct ContentView : View {
@State private var isPlaying: Bool = false
var body: some View {
VStack {
Text(isPlaying ? "Playing" : "Not Playing")
PlayButton()
Image(systemName: isPlaying ? "pause.circle" : "play.circle")
}
}
}
#if DEBUG
struct ContentView_Previews : PreviewProvider {
static var previews: some View {
ContentView()
}
}
#endifand the (simplified) play button code:
import SwiftUI
struct PlayButton : View {
@Binding var isPlaying: Bool
var body: some View {
Button(action: { self.isPlaying.toggle() }) {
Text( isPlaying ? "Stop" : "Play")
}
}
}
#if DEBUG
struct PlayButton_Previews : PreviewProvider {
static var previews: some View {
PlayButton(isPlaying: Binding)
}
}
#endif