【发布时间】:2014-09-12 15:20:29
【问题描述】:
当我这样做时从编译器那里得到投诉
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 关键字。
【问题讨论】:
标签: swift xcode6 swift-playground