4 @objc(SetValueTransformer)
5 class SetValueTransformer: ValueTransformer {
6 override class func transformedValueClass() -> AnyClass {
10 override class func allowsReverseTransformation() -> Bool {
14 override func transformedValue(_ value: Any?) -> Any? {
16 guard let value = value else {
19 return try NSKeyedArchiver.archivedData(withRootObject: value, requiringSecureCoding: true)
21 os_log("Failed to serialize a Set: %@", log: tplogDebug, type: .default, error as CVarArg)
26 override func reverseTransformedValue(_ value: Any?) -> Any? {
28 guard let dataOp = value as? Data? else {
31 guard let data = dataOp else {
35 let unarchiver = try NSKeyedUnarchiver(forReadingFrom: data)
36 return unarchiver.decodeObject(of: [NSSet.self], forKey: NSKeyedArchiveRootObjectKey)
38 os_log("Failed to deserialize a purported Set: %@", log: tplogDebug, type: .default, error as CVarArg)
43 static let name = NSValueTransformerName(rawValue: "SetValueTransformer")