Skip to content

Instantly share code, notes, and snippets.

@barbaramartina
Created November 4, 2017 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barbaramartina/a6a4263a3d9ecddfcf0f3acdd285ee05 to your computer and use it in GitHub Desktop.
Save barbaramartina/a6a4263a3d9ecddfcf0f3acdd285ee05 to your computer and use it in GitHub Desktop.
// Create a persistent container with an specific description for the stores
private(set) lazy var container: NSPersistentContainer = {
let description = NSPersistentStoreDescription()
description.type = NSSQLiteStoreType
description.shouldInferMappingModelAutomatically = false
description.shouldMigrateStoreAutomatically = true
let container = NSPersistentContainer(name: CoreDataStackTheNewWay.modelName)
container.persistentStoreDescriptions = [description]
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
if let error = error as NSError? {
fatalError("Unresolved error \(error), \(error.userInfo)")
}
})
return container
}()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment