Monday, March 11, 2024
HomeiOS Developmentios - If assertion with binding worth is inflicting app to crash

ios – If assertion with binding worth is inflicting app to crash


I’ve view parentView, view B and consider C.

View parentView is a guardian view and incorporates @State bool worth which is being handed into view B and from view B to view C. The view B is inside a if assertion and the assertion is managed from view C. Nonetheless, if I alter the worth in view C, it causes the app to crash.

Im utilizing iPhone 12 Professional, iOS 16.0.2.

Right here is parentView:

@primary
struct parentView: App {
    @State var isLogged: Bool = false
    
    
    var physique: some Scene {
        WindowGroup {
            ZStack {
                Colour("F6F6F6").edgesIgnoringSafeArea(.all)
                if isLogged == false {
                    ViewA(isLogged: $isLogged)
                }
            }
        }
    }
}

Right here is view B:

 struct ViewB: View {
        var isLogged: Binding<Bool>
        @State personal var loginNavigationIsActive = false
        
        
        var physique: some View {
            NavigationView {
                ZStack {
                    Button("GO") {
                        loginNavigationIsActive = true
                    }
                    NavigationLink(
                        "",
                        vacation spot: ViewC(isLogged: isLogged, loginNavigationIsActive: $loginNavigationIsActive),
                        isActive: $loginNavigationIsActive
                    )
                    .hidden()
                }
            }
        }
    }

Right here is view C:

 struct ViewC: View {
        var isLogged: Binding<Bool>
        var loginNavigationIsActive: Binding<Bool>
        
        var physique: some View {
            NavigationView {
                ZStack {
                    Button("BACK") {
                        isLogged.wrappedValue = true
                    }
                }
            }
        }
    }



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments