なぜそれが、私は、コードの行を持っている場合ということです。スウィフト単項演算エラー
Consecutive statements on a line must seperated with a ';'
と
Unary operator '+' cannot be applied to an operand of type 'String'
しかし、行はほぼ正確に同じで、編集中のラベルの別の名前以外は同じです。どんな助けもありがとう。
EDIT:
のフル機能:ラベルの
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!
* "ほぼ同じ" *は役に立たない、私たちは推測したくない。問題を示す*自己完結型*の例を投稿してください。 –
@Martinどういう意味ですか?私は、私が言っている2つの行がまったく同じで、ラベルの変数名を変更するとエラーが発生する理由を理解できないと言っているだけです。 –
問題が_前の行(または他の文脈)と関係していると思われます。問題の原因となっている_実際のコンテキスト_に実際のコード_を表示していない場合は、お手伝いできません。覚えておいて、私たちが知る必要があるかもしれないことを知らないので、周囲の文脈や 'moneyLabel'の宣言を含む十分な情報を表示してください。 – matt