Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在数据模型中声明了两个属性(currentTime和fullTime),Transformable如下所示。
currentTime
fullTime
Transformable
如何在此属性中保存数据?我需要先转换NSData吗?或任何其他方式?
NSData
Transformable 需要可转换为NSData. 当您使用符合NSCoding协议的类型时,这会自动发生。当您不是(与 一样CMTime)时,除非您通过子类化创建自己的自定义转换器,否则您不能使用可转换对象NSValueTransformer。
NSCoding
CMTime
NSValueTransformer
您可能会发现简单地将CMTime属性保存在 Core Data 中并从中重建它们会更容易CMTime。这些属性都是 Core Data 知道如何处理的数字类型。