I try to pass data from an @environmentObject to a @State object in the TopLevel
struct ContentView: View {
@EnvironmentObject var countRecognizer: themeCounter
@State var theme: themeModel = themeData[countRecognizer.themeCount]
@State var hideBar = true
var body: some View {
ZStack {
videoCard(theme: theme)
.statusBar(hidden: true)
Text("\(self.countRecognizer.themeCount)")
if hideBar == true {
}
}
But I am getting this error: "Cannot use instance member within property initializer; property initializers run before 'self' is available"
the themeData Array should get the Int from the environment Object.
How can I fix this problem?