WIP: ObjectRepresentable utilities

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

No files matched your search

@@ -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
}
}