WIP: ObjectRepresentable utilities

This commit is contained in:
John Estropia
2019-10-14 21:36:03 +09:00
parent f5a165d47d
commit 6b64eb7650
17 changed files with 315 additions and 198 deletions

View File

@@ -87,7 +87,7 @@ extension NSManagedObjectContext {
}
@nonobjc
internal func liveObject<D: DynamicObject>(id: NSManagedObjectID) -> LiveObject<D> {
internal func liveObject<D: DynamicObject>(objectID: NSManagedObjectID) -> LiveObject<D> {
let cache: NSMapTable<NSManagedObjectID, LiveObject<D>> = self.userInfo(for: .liveObjectsCache(D.self)) {
@@ -95,12 +95,12 @@ extension NSManagedObjectContext {
}
return Internals.with {
if let liveObject = cache.object(forKey: id) {
if let liveObject = cache.object(forKey: objectID) {
return liveObject
}
let liveObject = LiveObject<D>(id: id, context: self)
cache.setObject(liveObject, forKey: id)
let liveObject = LiveObject<D>(objectID: objectID, context: self)
cache.setObject(liveObject, forKey: objectID)
return liveObject
}
}