伙计们我在Utility类中编写了一个实用程序函数
func showAlert(vc: UIViewController) {
if #available(iOS 8.0, *) {
let alertController = UIAlertController(title: "title", message: "message.", preferredStyle: .Alert)
let defaultAction = UIAlertAction(title: "OK", style: .Default, handler: nil)
alertController.addAction(defaultAction)
vc.presentViewController(alertController, animated: true, completion: nil)
}
}
如果我从currentViewController调用此函数,则会出现类似
的错误答案 0 :(得分:2)
AppUtil
已经初始化了吗?如果不是,您需要调用AppUtil()
或在变量或其他任何内容中初始化它。