mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-21 00:49:49 +01:00
always create subclass type from cs_rawObject
This commit is contained in:
@@ -131,7 +131,12 @@ extension CoreStoreObject {
|
|||||||
}
|
}
|
||||||
return forceCast(coreStoreObject)
|
return forceCast(coreStoreObject)
|
||||||
}
|
}
|
||||||
let coreStoreObject = self.init(rawObject: object)
|
@inline(__always)
|
||||||
|
func forceTypeCast<T: CoreStoreObject>(_ type: DynamicObject.Type, to: T.Type) -> T.Type {
|
||||||
|
|
||||||
|
return type as! T.Type
|
||||||
|
}
|
||||||
|
let coreStoreObject = forceTypeCast(object.entity.dynamicObjectType!, to: self).init(rawObject: object)
|
||||||
object.coreStoreObject = coreStoreObject
|
object.coreStoreObject = coreStoreObject
|
||||||
return coreStoreObject
|
return coreStoreObject
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,17 @@ import Foundation
|
|||||||
|
|
||||||
internal extension NSEntityDescription {
|
internal extension NSEntityDescription {
|
||||||
|
|
||||||
|
@nonobjc
|
||||||
|
internal var dynamicObjectType: DynamicObject.Type? {
|
||||||
|
|
||||||
|
guard let userInfo = self.userInfo,
|
||||||
|
let typeName = userInfo[UserInfoKey.CoreStoreManagedObjectTypeName] as! String? else {
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return (NSClassFromString(typeName) as! DynamicObject.Type)
|
||||||
|
}
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
internal var coreStoreEntity: DynamicEntity? {
|
internal var coreStoreEntity: DynamicEntity? {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user