0

I can't figure this out, referencing this post: Struggling with NSNumberFormatter in Swift for currency

I can't get a reference to NSNumberFormatter...i.e. I can't call any methods on formatter? (the below throws an error of expected declaration)

import Foundation

class CurrencyFormatter {

    var price = 100

    var formatter = NSNumberFormatter()
    formatter.numberStyle = .CurrencyStyle
    formatter.stringFromNumber(price)



}

enter image description here

Community
  • 1
  • 1
GarySabo
  • 4,922
  • 5
  • 35
  • 95

1 Answers1

0
class CurrencyFormatter {

    var price = 100

    var formatter = NSNumberFormatter()

    init() {
        formatter.numberStyle = .CurrencyStyle
        formatter.stringFromNumber(price)
    }
}
Will M.
  • 1,824
  • 16
  • 27