沒有初始化充分利用編譯器的投訴,當我這樣做班「的ViewController」在迅速
class ViewController: UIViewController {
var delegate : AppDelegate
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
//self.appDelegate = UIApplication.sharedApplication().delegate;
}
@IBAction func getData(sender : AnyObject) {
}
@IBAction func LogOut(sender : AnyObject) {
}
}
不過,如果我只是添加?結束時AppDelegate像下面一樣,錯誤消失了。
class ViewController: UIViewController {
var delegate : AppDelegate?
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
//self.appDelegate = UIApplication.sharedApplication().delegate;
}
@IBAction func getData(sender : AnyObject) {
}
@IBAction func LogOut(sender : AnyObject) {
}
}
我沒有看到相關optional
關鍵字這個錯誤,除非我錯了。
可怕的錯誤語法的值初始化imo – Magoo 2016-09-14 09:54:53
代碼請解釋,代碼說明 – Martian2049 2017-09-19 02:25:59