gpt4 book ai didi

ios - 代码 : CoreData generated property is "double" instead of "NSNumber"

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:27:34 25 4
gpt4 key购买 nike

我在使用 CoreData 时遇到问题:数据模型有多个类型为 Double 的字段:

field1 field2

因此,我希望生成的 CoreData 属性属于同一类型,但是,它们不是:

@property (nullable, nonatomic, copy) NSNumber *amount;
@property (nonatomic) double iccsMaterialAmountIfDifferentThanPlanItem;

这种行为的根本原因是什么,是错误吗?如果是,如何解决?

最佳答案

这是 Xcode 自动生成类的默认行为,您可以在属性上选择 Use scalar type 来更改它:

来自doc :

Use Scalar Type Optionally, for some types, choose between scalar and non-scalar representations during code generation. For a Double, selecting the Use Scalar checkbox produces a Double, while leaving it unselected produces an NSNumber. For the full list of types, including scalar variants, see NSAttributeType.

关于ios - 代码 : CoreData generated property is "double" instead of "NSNumber",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57757107/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com