Is NSNumberFormatter the only way to format an NSDecimalNumber?

后端 未结 4 1323
借酒劲吻你
借酒劲吻你 2020-12-31 11:20

I\'m using an NSDecimalNumber to store money in Core Data. I naively used stringWithFormat: at first to format the value, later realizing that it didn\'t support NSDecimalNu

4条回答
  •  天命终不由人
    2020-12-31 12:10

    There's nothing wrong with that approach, and it's the conventional pattern to convert opaque number classes to strings.

    If I have a UIView that uses a formatter often, I'll usually have one as an instance member so I avoid having to repeatedly alloc/init/release the formatter.

提交回复
热议问题