Skip to content

Commit 79679c9

Browse files
committed
Update PersistentContainerStorage.init()
1 parent f7977e3 commit 79679c9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Sources/CoreDataModel/NSPersistentContainer.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,21 @@ public actor PersistentContainerStorage: ModelStorage, ObservableObject {
6868

6969
// MARK: Initialization
7070

71-
public init(name: String, model: Model) {
71+
public init(
72+
name: String,
73+
model: Model,
74+
storeDescriptions: [NSPersistentStoreDescription] = []
75+
) {
7276
let managedObjectModel = NSManagedObjectModel(model: model)
7377
let persistentContainer = NSPersistentContainer(
7478
name: name,
7579
managedObjectModel: managedObjectModel
7680
)
7781
self.persistentContainer = persistentContainer
82+
// use custom store descriptions
83+
if storeDescriptions.isEmpty == false {
84+
persistentContainer.persistentStoreDescriptions = storeDescriptions
85+
}
7886
}
7987

8088
// MARK: Properties

0 commit comments

Comments
 (0)