I am trying to implement a logout button in my application using swift. Users are authenticated through firebase. This is the function that I am currently working on:
@IBAction func buttonLogOut(_ sender: Any) {
do
{
try Auth.auth().signOut()
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let loginVC = storyboard.instantiateViewController(withIdentifier: "login View Controller") as! loginVC
let appDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.window?.rootViewController = loginVC
self.performSegue(withIdentifier: "Dashboard", sender: self)
}
catch let error as NSError
{
print(error.localizedDescription)
}
}
}
I am getting these errors on the following lines and Im unsure how to solve this
let loginVC = storyboard.instantiateViewController(withIdentifier: "loginViewController") as! Main
Cannot find type 'Main' in scope
And
appDelegate.window?.rootViewController = loginVC
Value of type 'AppDelegate' has no member 'window'