我在另一個類的單獨的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'
如何創建一個彈出窗口,告知出現了錯誤的用戶?