I have a swift UIHostingController which renders a SwiftUI. I call a function in view did appear which builds fine but doesn't create the intended output.
class LoginView: UIHostingController<LoginViewComponent> {
required init?(coder: NSCoder) {
super.init(coder: coder, rootView: LoginViewComponent())
}
override func viewDidAppear(_ animated: Bool) {
sessionHandler()
}
func sessionHandler(){
let user = User()
if user.isLoggedIn(){
view.isUserInteractionEnabled = false
print("Authenticating Session")
self.rootView.loginState(state: "success")
}else{
view.isUserInteractionEnabled = true
print("Needs Logging in")
}
}
}
The function ("loginState(state: "success")") works when called within the SwiftUI view class, however when called from the hosting controller it doesn't work.
Any help would be greatly appreciated.