我在另一个类的单独的swift文件中有以下的Swift 3代码。如何显示不是UIViewController的另一个类的警报弹出窗口?
class Login{
func showAlert(message :String){
let alertController2 = UIAlertController(title: "Error", message: "A error occured when checking credentials, try again later.", preferredStyle: .alert)
let defaultAction = UIAlertAction(title: "OK", style: .default, handler: nil)
alertController2.addAction(defaultAction)
self.present(alertController2, animated: true, completion: nil)
}
}
但我得到一个红色的错误:
Use of unresolved identifier 'UIAlertController'
如何创建一个弹出窗口,告知出现了错误的用户?