DynamicSchema
public protocol DynamicSchema
DynamicSchema
are types that provide NSManagedObjectModel
instances for a single model version. CoreStore currently supports the following concrete types:
XcodeDataModelSchema
: describes models loaded from a .xcdatamodeld file.UnsafeDataModelSchema
: describes models loaded directly from an existingNSManagedObjectModel
. It is not advisable to continue using this model as its metadata are not available to CoreStore.CoreStoreSchema
: describes models written forCoreStoreObject
Swift class declarations.
-
The version string for this model schema.
Declaration
Swift
var modelVersion: ModelVersion { get }
-
Do not call this directly. The
NSManagedObjectModel
for this schema may be created lazily and using this method directly may affect the integrity of the model.Declaration
Swift
func rawModel() -> NSManagedObjectModel
-
printCoreStoreSchema()
Extension methodPrints the
DynamicSchema
as their correspondingCoreStoreObject
Swift declarations. This is useful for converting currentXcodeDataModelSchema
-based models into the newCoreStoreSchema
framework. Additional adjustments may need to be done to the generated source code; for example:Transformable
concrete types need to be provided, as well asdefault
values.Important
After transitioning to the newCoreStoreSchema
framework, it is recommended to add the new schema as a new version that the existing versions’XcodeDataModelSchema
can migrate to. It is discouraged to load existing SQLite files created withXcodeDataModelSchema
directly into aCoreStoreSchema
.Declaration
Swift
public func printCoreStoreSchema() -> String
Return Value
a string that represents the source code for the
DynamicSchema
as their correspondingCoreStoreObject
Swift declarations.