mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-04-17 22:49:41 +02:00
minor
This commit is contained in:
@@ -356,7 +356,7 @@ extension ObjectPublisher where O: NSManagedObject {
|
|||||||
public func value<V: AllowedObjectiveCKeyPathValue>(forKeyPath keyPath: KeyPath<O, V>) -> V! {
|
public func value<V: AllowedObjectiveCKeyPathValue>(forKeyPath keyPath: KeyPath<O, V>) -> V! {
|
||||||
|
|
||||||
let key = String(keyPath: keyPath)
|
let key = String(keyPath: keyPath)
|
||||||
return self.snapshot?.dictionaryForValues()[key] as! V?
|
return self.snapshot?.dictionaryForValues()[key] as? V
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -120,11 +120,15 @@ public struct ObjectSnapshot<O: DynamicObject>: ObjectRepresentation, Hashable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// MARK: FilePrivate
|
||||||
|
|
||||||
|
fileprivate var values: [String: Any]
|
||||||
|
|
||||||
|
|
||||||
// MARK: Private
|
// MARK: Private
|
||||||
|
|
||||||
private let id: O.ObjectID
|
private let id: O.ObjectID
|
||||||
private let context: NSManagedObjectContext
|
private let context: NSManagedObjectContext
|
||||||
private var values: [String: Any]
|
|
||||||
|
|
||||||
private var valuesRef: NSDictionary {
|
private var valuesRef: NSDictionary {
|
||||||
|
|
||||||
@@ -153,7 +157,16 @@ extension ObjectSnapshot where O: NSManagedObject {
|
|||||||
public func value<V: AllowedObjectiveCKeyPathValue>(forKeyPath keyPath: KeyPath<O, V>) -> V! {
|
public func value<V: AllowedObjectiveCKeyPathValue>(forKeyPath keyPath: KeyPath<O, V>) -> V! {
|
||||||
|
|
||||||
let key = String(keyPath: keyPath)
|
let key = String(keyPath: keyPath)
|
||||||
return self.values[key] as! V?
|
return self.values[key] as? V
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Mutates the value for the property identified by a given key.
|
||||||
|
*/
|
||||||
|
public mutating func setValue<V: AllowedObjectiveCKeyPathValue>(_ value: V!, forKeyPath keyPath: KeyPath<O, V>) {
|
||||||
|
|
||||||
|
let key = String(keyPath: keyPath)
|
||||||
|
self.values[key] = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,7 +200,7 @@ extension ObjectSnapshot where O: CoreStoreObject {
|
|||||||
get {
|
get {
|
||||||
|
|
||||||
let key = String(keyPath: member)
|
let key = String(keyPath: member)
|
||||||
return self.values[key] as! V?
|
return self.values[key] as? V
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
|
|
||||||
@@ -221,7 +234,7 @@ extension ObjectSnapshot where O: CoreStoreObject {
|
|||||||
get {
|
get {
|
||||||
|
|
||||||
let key = String(keyPath: member)
|
let key = String(keyPath: member)
|
||||||
return self.values[key] as! V?
|
return self.values[key] as? V
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
|
|
||||||
@@ -238,7 +251,7 @@ extension ObjectSnapshot where O: CoreStoreObject {
|
|||||||
get {
|
get {
|
||||||
|
|
||||||
let key = String(keyPath: member)
|
let key = String(keyPath: member)
|
||||||
guard let id = self.values[key] as! D.ObjectID? else {
|
guard let id = self.values[key] as? D.ObjectID else {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ public struct PartialObject<O: CoreStoreObject> {
|
|||||||
*/
|
*/
|
||||||
public func value<V>(for property: (O) -> TransformableContainer<O>.Optional<V>) -> V? {
|
public func value<V>(for property: (O) -> TransformableContainer<O>.Optional<V>) -> V? {
|
||||||
|
|
||||||
return self.rawObject.value(forKey: property(O.meta).keyPath) as! V?
|
return self.rawObject.value(forKey: property(O.meta).keyPath) as? V
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -212,7 +212,7 @@ public struct PartialObject<O: CoreStoreObject> {
|
|||||||
*/
|
*/
|
||||||
public func primitiveValue<V>(for property: (O) -> TransformableContainer<O>.Optional<V>) -> V? {
|
public func primitiveValue<V>(for property: (O) -> TransformableContainer<O>.Optional<V>) -> V? {
|
||||||
|
|
||||||
return self.rawObject.primitiveValue(forKey: property(O.meta).keyPath) as! V?
|
return self.rawObject.primitiveValue(forKey: property(O.meta).keyPath) as? V
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -380,7 +380,7 @@ public enum TransformableContainer<O: CoreStoreObject> {
|
|||||||
|
|
||||||
return customGetter(PartialObject<O>(object))
|
return customGetter(PartialObject<O>(object))
|
||||||
}
|
}
|
||||||
return object.value(forKey: self.keyPath) as! V?
|
return object.value(forKey: self.keyPath) as? V
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
@@ -489,7 +489,7 @@ public enum TransformableContainer<O: CoreStoreObject> {
|
|||||||
}
|
}
|
||||||
customSetter(
|
customSetter(
|
||||||
PartialObject<O>(rawObject),
|
PartialObject<O>(rawObject),
|
||||||
newValue as! V?
|
newValue as? V
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user