I have loaded a specific URL file in persistentContainer using the following:
// MARK: Core Data Stack
lazy var persistentContainer: NSPersistentContainer = {
os_log("In persistent Container", log: OSLog.default, type: .debug)
// set URL to game file location
let urls = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
let docURL = urls[urls.endIndex-1]
let storeURL = docURL.appendingPathComponent(Singleton.sharedInstance.mainGameFileName!)
let container = NSPersistentContainer(name: "RefGameData")
container.persistentStoreDescriptions = [NSPersistentStoreDescription(url: storeURL)]
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
if let error = error as NSError? {
fatalError("Unresolved error \(error), \(error.userInfo)")
}
})
return container
}()
I want to remove that particular URL file and replace it with a different file when I need to load a different game's data. I have not be able to locate in the Apple documentation for persistentContainer any equivalent to container.unloadPersistentStores(....)
I am a noobie in Swift programming and any thoughts would be appreciated.