6

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

rmaddy
  • 314,917
  • 42
  • 532
  • 579
belab
  • 117
  • 3
  • 12

1 Answers1

11

Try

Label.text = numberFormatter.string(from: NSNumber(value: value))
Cruz
  • 2,602
  • 19
  • 29
  • Thank you, it works. But only in this case. I have some map-stuff in my app and here: lblLocation.text = "\(numberFormatter.string(from: NSNumber(latestLocation.coordinate.latitude: latestLocation.coordinate.latitude))) still error – belab Oct 03 '16 at 16:46
  • hmm how about lblLocation.text = numberFormatter.string(from: NSNumber(value: latestLocation.coordinate.latitude)) – Cruz Oct 03 '16 at 16:48
  • Thanks! It works! :) dont know exactly why, but works! – belab Oct 03 '16 at 17:10