Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Sources/DataManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public final class DataManager {
private static var dataModelBundle: Bundle?
private static var persistentStoreName: String?
private static var persistentStoreType = PersistentStoreType.sqLite
private static var groupIdentifier: String?

/// The logger to use for logging errors caught internally. A default logger is used if a custom one isn't provided. Assigning nil to this property prevents DataManager from emitting any logs to the console.
public static var errorLogger: DataManagerErrorLogger? = DefaultLogger()
Expand All @@ -120,19 +121,24 @@ public final class DataManager {
- parameter bundle: The bundle in which the data model schema file resides.
- parameter persistentStoreName: The name of the persistent store.
- parameter persistentStoreType: The persistent store type. Defaults to SQLite.
- parameter groupIdentifier: The group identifier if exist. Defaults to nil
*/
public static func setUp(withDataModelName dataModelName: String, bundle: Bundle, persistentStoreName: String, persistentStoreType: PersistentStoreType = .sqLite) {
public static func setUp(withDataModelName dataModelName: String, bundle: Bundle, persistentStoreName: String, persistentStoreType: PersistentStoreType = .sqLite, groupIdentifier: String? = nil) {

DataManager.dataModelName = dataModelName
DataManager.dataModelBundle = bundle
DataManager.persistentStoreName = persistentStoreName
DataManager.persistentStoreType = persistentStoreType
DataManager.groupIdentifier = groupIdentifier
}

// MARK: Core Data Stack

private static var applicationDocumentsDirectory: URL = {

if let groupIdentifier = DataManager.groupIdentifier,
let urlGroup = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: groupIdentifier) {
return urlGroup
}
let urls = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
return urls[urls.count - 1]
}()
Expand Down