Bindings all of sudden not working in iOS14

416 views Asked by At

Prior to iOS 14 my project was working fine with the following code

struct LoginView: View, Resolving {

    @ObservedObject var loginUIService: LoginUIService = Resolver.resolve()
    ...
    var body: some View {
        ...
        TextField(LocalizedString.Placeholder.email.localized, text: self.$loginUIService.loginViewModel.emailAddress)
        ...
    }
}

This is my partial service class

class LoginUIService: ObservableObject, Resolving {
    
    @Published var loginViewModel: LoginViewModel = Resolver.resolve()
    ...
}

And then the view model

class LoginViewModel: ObservableObject {
    
    
    //MARK:- Properties
    @Published var emailAddress: String {
        didSet {
            checkIsValid()
        }
    }
    @Published var password: String{
        didSet {
            checkIsValid()
        }
    }
    @Published var isValid = false

    
    //MARK:- Init Methods
    init() {
        emailAddress = ""
        password = ""
    }
    
    init(emailAddress: String, password: String) {
        self.emailAddress = emailAddress
        self.password = password
    }
    
    fileprivate func checkIsValid() {
        isValid = emailAddress.isEmpty == false && password.isEmpty == false && emailAddress.contains("@")
    }
    
}

In iOS 13 this code all works 100% without any issues and now when running on an iOS14 device I am getting the following output in the console when tapping on the textfields

Binding<String>(transaction: SwiftUI.Transaction(plist: []), location: SwiftUI.LocationBox<SwiftUI.(unknown context at $7fff562e301c).ProjectedLocation<SwiftUI.LocationBox<SwiftUI.ObservableObjectLocation<Recon.LoginUIService, Recon.LoginViewModel>>, Swift.WritableKeyPath<Recon.LoginViewModel, Swift.String>>>, _value: "")

Has anyone experience this issue recently ?

0

There are 0 answers