为什么当我有一行代码时呢?
MoneyScreen1.text = "£" + String(moneyConstants.money) + ".00"
然而,在我的项目的另一个文件中,我有:
moneyLabel.text = "£" + String(moneyConstants.money) + ".00"
但我得到两个错误:
Consecutive statements on a line must seperated with a ';'
和
Unary operator '+' cannot be applied to an operand of type 'String'
但除了正在编辑的标签的不同名称之外,该行几乎完全相同。任何帮助将不胜感激。
编辑:
全功能:
func checkValues() {
moneyLabel.text = "£" + String(moneyConstants.money) + ".00"
let savedValues = UserDefaults.standard
savedValues.setValue(moneyConstants.money, forKey: "money")
savedValues.setValue(buildingLevels.jitterClickNumber, forKey:"jitterClickBuildingLevel")
savedValues.setValue(buildingLevels.macrosNumber , forKey:"macrosBuildingLevel")
savedValues.setValue(buildingLevels.autoClickerNumber , forKey:"autoClickerBuildingLevel")
savedValues.setValue(buildingLevels.anotherPCNumber, forKey:"anotherPCBuildingLevel")
savedValues.setValue(buildingLevels.workerNumber , forKey:"workerBuildingLevel")
savedValues.setValue(buildingLevels.houseNumber , forKey:"houseBuildingLevel")
savedValues.setValue(buildingLevels.officeNumber , forKey:"officeBuildingLevel")
savedValues.setValue(buildingLevels.skyriseNumber , forKey:"skyriseBuildingLevel")
savedValues.setValue(buildingLevels.planetNuber , forKey:"planetBuildingLevel")
jitterClickCostLabel.text = "£" + String(buildingConstants.jitterClickConstantCost) + ".00"
macrosCostLabel.text = "£" + String(buildingConstants.macrosConstantCost) + ".00"
autoClickerCostLabel.text = "£" + String(buildingConstants.autoClickerConstantCost) + ".00"
anotherPCCostLabel.text = "£" + String(buildingConstants.anotherPCConstantCost) + ".00"
workerCostLabel.text = "£" + String(buildingConstants.workerConstantCost) + ".00"
houseCostLabel.text = "£" + String(buildingConstants.houseConstantCost) + ".00"
officeCostLabel.text = "£" + String(buildingConstants.officeConstantCost) + ".00"
skyriseCostLabel.text = "£" + String(buildingConstants.skyriseConstantCost) + ".00"
planetCostLabel.text = "£" + String(buildingConstants.planetConstantCost) + ".00"
moneyLabel.text = "£" + String(moneyConstants.money) + ".00"
}
标签声明:
@IBOutlet var moneyLabel: UILabel!