WIP: SwiftUI utils

This commit is contained in:
John Estropia
2020-12-26 19:21:46 +09:00
parent 477f478d85
commit 9406901b28
5 changed files with 138 additions and 0 deletions

View File

@@ -67,6 +67,11 @@ public protocol ObjectRepresentation {
A thread-safe `struct` that is a full-copy of the object's properties
*/
func asSnapshot(in transaction: BaseDataTransaction) -> ObjectSnapshot<ObjectType>?
/**
Used internally by CoreStore. Do not call directly.
*/
func cs_dataStack() -> DataStack?
}
extension NSManagedObject: ObjectRepresentation {}
@@ -142,4 +147,9 @@ extension DynamicObject where Self: ObjectRepresentation {
let context = transaction.unsafeContext()
return ObjectSnapshot<Self>(objectID: self.cs_id(), context: context)
}
public func cs_dataStack() -> DataStack? {
return self.cs_toRaw().managedObjectContext?.parentStack
}
}