This is a template for a Core Data stack which can be used in apps needing basic support for background writes, main thread access, and a background context for work. It has been ported to Swift from an Objective-C repo.
To init the stack:
let coreDataStack = CoreDataStack(
dataModelFilename: "ExampleModel",
storeFilename: "ExampleDatabase",
inMemory: false,
dumpInvalidStore: true,
finished: { (success, error) in
if success {
print("successfully opened core data store")
} else {
print("failed to open core data store: \(error)")
}
})
Copy and paste CoreDataStack.swift
into your project.
Kyle Zaragoza, popwarsweet@gmail.com
CoreDataStack is available under the MIT license. See the LICENSE file for more info.