We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 86720f5 commit 768502fCopy full SHA for 768502f
Sources/ManagedModels/PersistentModel/PersistentModel+KVC.swift
@@ -31,7 +31,15 @@ public extension PersistentModel {
31
where T: Codable & CoreDataPrimitiveValue & AnyOptional
32
{
33
willChangeValue(forKey: key); defer { didChangeValue(forKey: key) }
34
- setPrimitiveValue(value, forKey: key)
+
35
+ // While `nil` is properly bridged to `NSNull`, this is still necessary
36
+ // because `T` is the Optional structure, NOT the value type. I think :-)
37
+ if value.isSome {
38
+ setPrimitiveValue(value.value, forKey: key)
39
+ }
40
+ else {
41
+ setPrimitiveValue(nil, forKey: key)
42
43
}
44
@inlinable
45
func getValue<T>(forKey key: String) -> T
0 commit comments