Skip to content

Commit 4703402

Browse files
committed
Add new type based convenience init for ModelConfiguration
... create a managed model.
1 parent e1d08df commit 4703402

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Sources/ManagedModels/Container/ModelConfiguration.swift

+10
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,13 @@ public extension ModelConfiguration {
117117

118118
public extension ModelConfiguration {
119119

120+
@inlinable
120121
var url : URL {
121122
set { path = newValue.path }
122123
get { URL(fileURLWithPath: path) }
123124
}
124125

126+
@inlinable
125127
init(_ name: String? = nil, schema: Schema? = nil, url: URL,
126128
isStoredInMemoryOnly: Bool = false, allowsSave: Bool = true,
127129
groupAppContainerIdentifier: String? = nil,
@@ -138,6 +140,14 @@ public extension ModelConfiguration {
138140
groupContainer: groupContainer,
139141
cloudKitDatabase: cloudKitDatabase)
140142
}
143+
144+
@inlinable
145+
init(for forTypes: any PersistentModel.Type...,
146+
isStoredInMemoryOnly: Bool = false)
147+
{
148+
let model = NSManagedObjectModel(forTypes)
149+
self.init(schema: model, isStoredInMemoryOnly: isStoredInMemoryOnly)
150+
}
141151
}
142152

143153
private func lookupDefaultPath(for name: String?) throws -> String {

0 commit comments

Comments
 (0)