Last active
September 7, 2017 02:25
-
-
Save koromiko/95dd912dbd495150db1fd35542adbe0c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lazy var mockPersistantContainer: NSPersistentContainer = { | |
let container = NSPersistentContainer(name: "PersistentTodoList", managedObjectModel: self.managedObjectModel) | |
let description = NSPersistentStoreDescription() | |
description.type = NSInMemoryStoreType | |
description.shouldAddStoreAsynchronously = false // Make it simpler in test env | |
container.persistentStoreDescriptions = [description] | |
container.loadPersistentStores { (description, error) in | |
// Check if the data store is in memory | |
precondition( description.type == NSInMemoryStoreType ) | |
// Check if creating container wrong | |
if let error = error { | |
fatalError("Create an in-mem coordinator failed \(error)") | |
} | |
} | |
return container | |
}() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment