always create subclass type from cs_rawObject

This commit is contained in:
John Rommel Estropia
2017-10-07 00:56:19 +09:00
parent fa682215c5
commit 8d86425875
2 changed files with 17 additions and 1 deletions

View File

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