是否覆盖lazy
属性合法的属性?
以下代码输出:
Created CardMatchingGame (Matchismo, mode: 1, 30 cards)
致命错误:在展开可选值"
时意外发现nil
这意味着创建了Matchismo游戏,但后来找不到基类函数updateScoreLabel()。
class CardGameViewController: UIViewController {
var game: CardMatchingGame!
@IBOutlet var scoreLabel: UILabel!
...
func updateScoreLabel() {
self.scoreLabel.text = "Score: \(self.game.getGameScore())"
}
...
}
class PlayingCardGameViewController: CardGameViewController {
lazy override var game: CardMatchingGame! = MatchismoGame()
...
}