核心数据-货币的小数类型 [英] Core Data - Decimal Type for Currency

查看:78
本文介绍了核心数据-货币的小数类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在最近的一篇文章中读到,由于十进制数据类型没有浮点问题,因此最适合在Core Data中用于建模货币。

I read in a recent post that the Decimal data type is the best to use in Core Data to model currency since it doesn't have floating point issues.

我已经搜索了苹果文档和Google,似乎找不到使用Decimal类型的任何文档。

I've searched the apple docs and google and can't seem to find any documentation on using the Decimal type.

是否有人链接到它的文档?

Does anyone have a link to documentation on it?

谢谢!

推荐答案

使用十进制作为属性类型您的数据模型,并将NSDecimalNumber作为代码中的对象类型。

Use "Decimal" as the attribute type in your data model and NSDecimalNumber as the object type in your code.

这篇关于核心数据-货币的小数类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆