Меня немного смущает ошибка преобразования.
Я перенес свой проект из 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)
должно быть одно и то же.