当我这样做时,从编译器得到投诉
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除非我错了,否则我看不到与此错误相关的关键字。