Search code examples
iosswift3nsnumbernsnumberformatter

issue with NSNumber in swift 3


I have converted my project to swift 3, and I have a problem with NSNumber that I cannot deal with. Here's my number formatter declaration

let numberFormatter: NumberFormatter = {
    let nf = NumberFormatter()
    nf.numberStyle = .decimal
    nf.minimumFractionDigits = 0
    nf.maximumFractionDigits = 1
    return nf
}()

and here's place with error. Value is a double, sure that other things ale fine.

Label.text = numberFormatter.string(from: NSNumber(value))

Message from debugger:

Arguments labels '(_:)' do not match any available overloads

Before conversion everything worked. Please help, I cannot find


Solution

  • Try

    Label.text = numberFormatter.string(from: NSNumber(value: value))