I'm trying to save a Measurement to a Core Data transformable property. Basically, what's in this answer, only a different unit: How to Save a Generic Measurement<Unit> in Core Data?
Everything works, however I'm getting this message in the log:
[general] 'NSKeyedUnarchiveFromData' should not be used to for un-archiving and will be removed in a future release
I'm not sure how to fix this. Or what exactly it means. This is my first time working with a transformable Core Data property.
Thanks
Edit:
I made a new class:
import Foundation
@objc(UnitTemperatureValueTransformer)
final class UnitTemperatureValueTransformer: NSSecureUnarchiveFromDataTransformer {
static let name = NSValueTransformerName(rawValue: String(describing: UnitTemperatureValueTransformer.self))
override static var allowedTopLevelClasses: [AnyClass] {
return [UnitTemperature.self]
}
public static func register() {
let transformer = UnitTemperatureValueTransformer()
ValueTransformer.setValueTransformer(transformer, forName: name)
}
}
And then I set the transformer value for the Core Data object to: UnitTemperatureValueTransformer
.
Is that all that needs to be done?
question from:
https://stackoverflow.com/questions/65545591/transformable-and-nskeyedunarchivefromdata 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…