I'm trying to present an alert after user logs out. I want this to disappear after, let's say, 3 seconds. I've followed some solution on UIAlert in Swift that automatically disappears?
Following is my code. The problem I'm facing is that after user logs out the I'm navigating away to another view (Home VC) hence I'm getting error:
dismissAlert]: unrecognized selector sent to instance
How do I make it work in this scenario?
let alert = UIAlertController(title: "", message: "Logged out", preferredStyle: .alert)
let cancelAction = UIAlertAction(title: "Ok", style: .cancel, handler: nil)
alert.addAction(cancelAction)
UIApplication.shared.keyWindow?.rootViewController!.present(alert, animated: true, completion: nil)
_ = Timer.scheduledTimer(timeInterval: Double(3), target: self, selector: Selector(("dismissAlert")), userInfo: nil, repeats: false)