mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Merge pull request #651 from omnivore-app/feature/core-data-app-group
Store sqlite file in app group file container [iOS]
This commit is contained in:
commit
b87f068193
1 changed files with 7 additions and 0 deletions
|
|
@ -12,6 +12,13 @@ public class PersistentContainer: NSPersistentContainer {
|
|||
let model = NSManagedObjectModel(contentsOf: modelURL)!
|
||||
let container = PersistentContainer(name: "DataModel", managedObjectModel: model)
|
||||
|
||||
// Store the sqlite file in the app group container.
|
||||
// This allows shared access for app and app extensions.
|
||||
let appGroupID = "group.app.omnivoreapp"
|
||||
let appGroupContainer = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: appGroupID)
|
||||
let appGroupContainerURL = appGroupContainer?.appendingPathComponent("store.sqlite")
|
||||
container.persistentStoreDescriptions.first!.url = appGroupContainerURL
|
||||
|
||||
container.viewContext.automaticallyMergesChangesFromParent = true
|
||||
container.viewContext.name = "viewContext"
|
||||
container.viewContext.mergePolicy = NSMergePolicy.mergeByPropertyObjectTrump
|
||||
|
|
|
|||
Loading…
Reference in a new issue