mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-04-11 03:36:51 +02:00
fix fixits
This commit is contained in:
@@ -149,6 +149,25 @@ public extension NSManagedObject {
|
|||||||
self.setPrimitiveValue(value, forKey: KVCKey)
|
self.setPrimitiveValue(value, forKey: KVCKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
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.
|
||||||
|
|
||||||
|
- 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) {
|
||||||
|
|
||||||
|
self.willChangeValue(forKey: KVCKey)
|
||||||
|
defer {
|
||||||
|
|
||||||
|
self.didChangeValue(forKey: KVCKey)
|
||||||
|
}
|
||||||
|
self.setPrimitiveValue(value, forKey: KVCKey)
|
||||||
|
didSetValue()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
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:)`. This is useful when implementing mutator methods for transient attributes.
|
||||||
|
|
||||||
@@ -228,7 +247,7 @@ public extension NSManagedObject {
|
|||||||
self.setPrimitiveValue(value, forKey: KVCKey)
|
self.setPrimitiveValue(value, forKey: KVCKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
@available(*, deprecated, renamed: "setValue(_:forKvcKey:willSetValue:didSetValue:)")
|
@available(*, deprecated, renamed: "setValue(_:forKvcKey:didSetValue:)")
|
||||||
@discardableResult
|
@discardableResult
|
||||||
@nonobjc
|
@nonobjc
|
||||||
public func setValue<T>(_ value: Any?, forKVCKey KVCKey: KeyPath, _ didSetPrimitiveValue: (Any?) throws -> T) rethrows -> T {
|
public func setValue<T>(_ value: Any?, forKVCKey KVCKey: KeyPath, _ didSetPrimitiveValue: (Any?) throws -> T) rethrows -> T {
|
||||||
|
|||||||
Reference in New Issue
Block a user