0
我使用了一個輔助類來實現一些功能,包括一個UIAlertController,它可以從我的應用程序中的其他地方訪問,但是我有問題從助手類本身訪問它。UIAlertController在Swift 3.0中使用助手類
func showAlert(title: String, msg: String, controller: UIViewController) {
let alert = UIAlertController(title: title, message: msg, preferredStyle: .alert)
let action = UIAlertAction(title: "OK", style: .default, handler: nil)
alert.addAction(action)
controller.present(alert, animated: true, completion: nil)
}
從類之外,我可以沒有任何問題叫它:
Helper.helper.showAlert(title: "Not Internet Detected", msg: "Data Connectivity is Required", controller: self)
從類中
不過,我得到一個錯誤:
showAlert(title: "Email in use, did you use another method to register", msg: "please try again", controller: self)
我得到的錯誤是:
Cannot convert value of type
Helper
to expected typeUIViewController
如何解決此問題問題?謝謝!