Im following a tutorial about SwiftUI and I am hitting a problem
the following is my effort to bind a boolean from one struct view to another
import SwiftUI
import Foundation
struct BindingTwo: View {
let episod = Episode(name: "MacBreak Weekly", track: "WWDC 2019")
@State private var isPlaying = false
var body: some View {
VStack{
Text(self.episod.name).font(.title).foregroundColor(self.isPlaying ? Color.green : Color.black)
Text(self.episod.track).foregroundColor(.secondary)
PlayButton(isPlaying: isPlaying)
}
}
}
struct PlayButton : View {
*@Binding var isPlaying : Bool* this line is generating the error
var body : some View {
Button(action: {self.isPlaying.toggle()}){
Text("Play")
}
.foregroundColor(Color.white)
.background(Color.black)
.padding(12)
}
}
but the @Binding line keeps getting the following error: "Struct 'Binding' cannot be used as an attribute" as far as I can tell this is the same as the tutorial, I cant figure out what it is I have missed, anybody see this before?