无法将类型为“字符串”的值分配为类型为“ UILabel?”

SR

我尝试对计算器进行编程。但是使用重置按钮,我不断出现以下错误消息:无法将类型为'String'的值分配给type UILabel?

我已经尝试更换labellabel.text

这是我的一些代码。错误消息出现在后面 label

if sender.tag == 11 {
    label = " "     
    previousNumber = 0;
    numberOnScreen = 0;
}
菲利普·米尔斯(Phillip Mills)

如果您将您label声明为Label?,请尝试:

if let realLabel = label {
    realLabel.text = "  "
} else {
    print("There is no label")
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章