我想要一個文本框來更新它的標籤,當我調用一個函數。 當我打電話時,我得到可選「」的返回並且文本字段變爲空白。下面是我的代碼..TextField不更新給我可選「」
func P18Switch() {
if metricImperialSwitch?.selectedSegmentIndex == 0
{
measurementSwitch = 0
CWLabel.text = "kg"; TWLabel.text = "kg"; CWaLabel.text = "cm"; TWaLabel.text = "cm"; CHLabel.text = "cm"; THLabel.text = "cm"
if CWeight.text == "" {
print("No go")
} else {
// b = 0.453592
// c = Double
// d = Double(CWeight.text!)
c = d! * b
CWeight.text = c as? String
print(CWeight.text)
}
}
我宣佈B,c和d更早
你不會得到在行「c as?String」的警告? – SaylorTwift2
沒有警告。 –