4

変換エラーについて少し混乱しています。

プロジェクトを Swift 2.3 から Swift 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 = "???"
    }
}

最初は、Swift 3.0 ではキャストが禁止されていると思っていましたType(value)が、確認したところ、コンパイラの警告はまったく表示されませんでした。誰かが何が問題なのか教えてもらえますかNSNumber(value)?

value as NSNumber私が理解している限りNSNumber(value)、同じことであるはずです。

4

2 に答える 2