Search code examples
objective-cswiftnsdecimalnumber

Convert NSDecimalNumber to String


How can I convert NSDecimalNumber values to String?

// Return type is NSDecimalNumber
var price = prod.minimumPrice // 10

// need a String
cell.priceLB.text = NSString(format:"%f", prod.minimumPrice) as String

Solution

  • You could try some of these options. They all should return 10. And also check why would you need to create NSString formatting the number and casting it to String.

    "\(price)"
    String(describing: price)
    NSString(format: "%@", price)