mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-15 05:33:31 +01:00
always create subclass type from cs_rawObject
This commit is contained in:
@@ -131,7 +131,12 @@ extension 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
|
||||
return coreStoreObject
|
||||
}
|
||||
|
||||
@@ -31,6 +31,17 @@ import Foundation
|
||||
|
||||
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
|
||||
internal var coreStoreEntity: DynamicEntity? {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user