我是swift3的新手.现在,我正在寻找一种从其他swift.file调用alert函数的方法
像这样:
//MainView.swift
//Call function
AlertFun.ShowAlert(title: "Title", message: "message..." )
//Another page for storing functions
//Function.swift
public class AlertFun {
class func ShowAlert(title: String, message: String ) {
let alert = UIAlertController(title: tile, message: message, preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.default, handler: nil))
self.present(alert, animated: true, completion: nil)
}
}
Run Code Online (Sandbox Code Playgroud)
问题在这里......不能这样做......
self.present(alert, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
我该如何实现它?谢谢.