save CMTime in core data + Xcode8 + swift3

171 Views Asked by At

I declared two attributes (currentTime and fullTime) as Transformable in data model as shown below.

enter image description here

How to save data in this attribute? Do I need to convert to NSData first? or any other way?

1

There are 1 best solutions below

0
On

Transformable need to be convertible to NSData. When you're using a type that conforms to the NSCoding protocol, that happens automatically. When you're not (as with CMTime), you can't use a transformable unless you create your own custom transformer by subclassing NSValueTransformer.

You may find it easier to simply save the CMTime properties in Core Data and reconstruct the CMTime from those. The properties are all numeric types that Core Data knows how to handle.