Yat*_*wal 2 objective-c nsdecimalnumber swift
有人请帮助我如何将nsdecimalnumber值转换为String这里是code.But无法正常工作.
// Return type is NSDecimalNumber
var price = prod.minimumPrice // 10
// need a String
cell.priceLB.text = NSString(format:"%f", prod.minimumPrice) as String
Run Code Online (Sandbox Code Playgroud)
您可以尝试其中一些选项.它们都应该返回10.还要检查为什么需要创建NSString格式化数字并将其转换为String.
"\(price)"
String(describing: price)
NSString(format: "%@", price)
Run Code Online (Sandbox Code Playgroud)
NSDecimalValue 继承自 NSNumber。
NSNumber 有stringValue属性
var stringValue: String { get }
The number object's value expressed as a human-readable string.
The string is created by invoking description(withLocale:) where locale is nil.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3662 次 |
| 最近记录: |