【发布时间】:2020-03-30 15:39:15
【问题描述】:
我尝试为我的项目添加评分系统:
var userRating: userRating! {
didSet {
good.setTitle("???? \(userRating.numberOfGood)", for: [])
}
}
@IBAction func goodReview(_ sender: UIButton) {
userRating.good() -> ERROR
good.setTitle("???? \(userRating.numberOfGood)", for: [])
}
userRating 类:
var numberOfGood = 0
func good() {
numberOfGood += 1
}
但每次我点击按钮时,我都会得到 Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value as an Error...
【问题讨论】: