用户基本上输入数字并点击按钮。然后将其添加到标签的值之上。但是,以下代码将其添加到字符串的末尾,并且不会物理添加字符串
let currentStamps = Int(labelStamps.text!)
let stamps = Int(textFieldStamps.text!)
labelStamps.text = stamps! + currentStamps!
请帮助
答案 0 :(得分:0)
试试这个:
if let currentStamps = Int(labelStamps.text!), let stamps = Int(textFieldStamps.text!) {
labelStamps.text = "\(stamps + currentStamps)"
}