嗨,我有问题打印到标签,这是输出。文本,它一直出来空白,但当我打印控制台,它显示的数字。
name.state = stateText.text
var stateName = [
["AK - Alaska", tax.alaska!],
["AL - Alabama", tax.alabama!],
["AR - Arkansas", tax.arkansas!],
["AZ - Arizona", tax.arizona!],
["CA - California", tax.california!]
]
for var i = 0; i < stateName.count; i++ {
if tax.state == stateName[i][0] {
stateName[i][1] = Double(taxNumb.text!)!
print(stateName[i][1])
output.text = stateName[i][1] as? String
}
}
最佳答案
不要强制转换为String
。你所拥有的是一个Double
,它不仅仅是可浇铸的String
。
您需要创建一个String
:
output.text = String(stateName[0][1])
或
output.text = "\(stateName[i][1])"