mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-11 21:11:58 +01:00
added ObjectSnapshot as foundation for datasources API
This commit is contained in:
@@ -60,6 +60,17 @@ public protocol DynamicObject: AnyObject {
|
||||
func cs_toRaw() -> NSManagedObject
|
||||
}
|
||||
|
||||
extension DynamicObject {
|
||||
|
||||
// MARK: Internal
|
||||
|
||||
internal func runtimeType() -> Self.Type {
|
||||
|
||||
// Self.self does not return runtime-created types
|
||||
return object_getClass(self)! as! Self.Type
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - NSManagedObject
|
||||
|
||||
@@ -98,6 +109,16 @@ extension NSManagedObject: DynamicObject {
|
||||
}
|
||||
}
|
||||
|
||||
extension DynamicObject where Self: NSManagedObject {
|
||||
|
||||
// MARK: Public
|
||||
|
||||
public func createSnapshot() -> ObjectSnapshot<Self> {
|
||||
|
||||
return ObjectSnapshot(from: self)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - CoreStoreObject
|
||||
|
||||
@@ -150,3 +171,13 @@ extension CoreStoreObject {
|
||||
return self.rawObject!
|
||||
}
|
||||
}
|
||||
|
||||
extension DynamicObject where Self: CoreStoreObject {
|
||||
|
||||
// MARK: Public
|
||||
|
||||
public func createSnapshot() -> ObjectSnapshot<Self> {
|
||||
|
||||
return ObjectSnapshot(from: self)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user