I have simple app in SwiftUI, when I use @Binding var show : Bool
for second register screen,
it is throw an error for this line of code
init(state: AppState) {
self.viewModel = RegisterViewModel(authAPI: AuthService(), state: state)
}
as a "Return from initializer without initializing all stored properties" any idea?
first screen:
import SwiftUI
struct RegisterFirstScreen: View {
@Binding var show : Bool
init(state: AppState) {
self.viewModel = RegisterViewModel(authAPI: AuthService(), state: state)
}
var body: some View {
NavigationLink(destination: RegisterSecondScreen(state: viewModel.state, show: $show),
isActive: self.$pushActive) {
Button {
viewModel.signUp()
} label: {
Text("Register Now")
.padding()
}
}
}
second screen:
struct RegisterSecondScreen: View {
@ObservedObject var state: AppState
@Binding var show : Bool
var body: some View {
Text("Next main screen")
}}