変換エラーについてちょっと混乱します。 Xcode 8.0とSwift 3.0の変換:特定の変換エラーの説明を探します
は、私が最初に私はスウィフト3.0キャストでType(value)
は現在禁止されたと思った時スウィフト3.0
func updateCelsiusLabel() {
if let value = celsiusValue {
//This was the original code (that worked but is) failing after migration
//due to: Argument labels do not match any available overloads
celsiusLabel.text = numberFormatter.string(from: NSNumber(value))
//This is my code trying to fix this issue and the project is now compiling
//and everything is fine
celsiusLabel.text = numberFormatter.string(from: value as NSNumber)
}
else { celsiusLabel.text = "???"
}
}
にスウィフト2.3私のプロジェクトフォームを移行したが、私はチェックして、私は絶対にないコンパイラの警告を取得していません。 NSNumber(value)
の問題は誰か教えてください。
私が理解する限り、value as NSNumber
とNSNumber(value)
は同じものでなければなりません。今では、私はちょうどのためのオプションの文字列としてテキストを取っていて、NumberFormatter celsiusLabel.textに名前が変更されました
てNumberFormatter = NSNumberFormatter()// -
と同じです。それはリンゴからの奇妙な脱獄のようなものですが、私は今それを手に入れます。 – Ruvi