![](/img/trans.png)
[英]Type HalfOpenInterval<T> does not conform to protocol BooleanType
[英]Type '()' does not conform to protocol 'BooleanType'
我正在尝试制作倒数计时器,当它下降到0秒时停止计时。 一切正常,但应该在o秒后停止。
如果您知道错误发生的原因或解决方法,请回答。
func stopAt() {
if countLabel.text = "0" {
if timerRunning == true {
timer.invalidate()
timerRunning = false
}
}
}
=
是分配, ==
是比较。 您想将 countLabel.text
与"0"
进行比较 ,而不要为countLabel.text
分配 "0"
。
func stopAt() {
if countLabel.text == "0" {
if timerRunning {
timer.invalidate()
timerRunning = false
}
}
}
而且,您无需显式地与true
或false
进行比较。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.