简体   繁体   中英

save CMTime in core data + Xcode8 + swift3

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

在此处输入图片说明

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM