Simply because, unlike a GMStepper
, a UILabel doesn't have a value
property. So you'll have to get the text
string in each label, convert it to a Double, and then add them up:
if let text1 = label1.text, let value1 = Double(text1),
let text2 = label2.text, let value2 = Double(text2),
let text3 = label3.text, let value3 = Double(text3),
let text4 = label4.text, let value4 = Double(text4) {
let sum = value1 + value2 + value3 + value4
label5.text = String(sum)
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…