我对转换错误有点困惑。Xcode 8.0和Swift 3.0转换:寻找特定转换错误的解释
我迁移我的项目形式雨燕2.3〜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 = "???"
}
}
起初我还以为是在雨燕3.0投Type(value)
是现在不允许,但我检查,我得到绝对没有编译器警告。有人可以告诉我NSNumber(value)
的问题是什么?
据我所知value as NSNumber
和NSNumber(value)
应该是一样的东西。
好的谢谢,这是从苹果奇怪的决定,但我现在得到它。 – Ruvi