accept optionals in setValue

This commit is contained in:
John Rommel Estropia
2017-05-21 09:38:56 +09:00
parent 6b3d75bea1
commit da3a9590ac

View File

@@ -150,14 +150,14 @@ public extension NSManagedObject {
}
/**
Provides a convenience wrapper for setting `setPrimitiveValue(_:forKey:)` with proper calls to `willChangeValue(forKey:)` and `didChangeValue(forKey:)`. This is useful when implementing mutator methods for transient attributes.
Provides a convenience wrapper for setting `setPrimitiveValue(_:forKey:)` with proper calls to `willChangeValue(forKey:)` and `didChangeValue(forKey:)`.
- parameter value: the value to set the KVC key with
- parameter KVCKey: the KVC key
- parameter didSetValue: called after executing `setPrimitiveValue(forKey:)`.
*/
@nonobjc @inline(__always)
public func setValue(_ value: Any, forKvcKey KVCKey: KeyPath, didSetValue: () -> Void) {
public func setValue(_ value: Any?, forKvcKey KVCKey: KeyPath, didSetValue: () -> Void) {
self.willChangeValue(forKey: KVCKey)
defer {