I am facing an issue while adding Timer inside the completion block of the present alert controller.
Error: Cannot convert value of type 'Timer' to expected argument type '(() -> Void)?'
func showAutoHideAlert() {
let alertController = UIAlertController(title: "title", message: "message", preferredStyle: .alert)
present(alertController, animated: true, completion: Timer.scheduledTimer(withTimeInterval: 3.0, repeats: false) { _ in
self.dismiss(animated: true, completion: nil)
})
}
Please help how to resolve this issue. Thanks