Reputation: 3697
I am trying to implement a log out button inside another view controller. The log out button currently removes all user defaults and clears any tokens from the keychain however I do not know how to display the home view controller and remove all other views from memory?
let rootView: HomeViewController = HomeViewController()
if let window = self.window{
window.rootViewController = rootView
}
doesn't seem to work inside another view controller.
Thanks
Upvotes: 0
Views: 566
Reputation: 2897
Try this code
if let window = self.view.window {
window.rootViewController = HomeViewController()
}
as window
is not member of UIViewController
, you need to access the window
using member view
of UIViewController
.
Upvotes: 0