     }
     
     
-    private func createMainContext() -> NSManagedObjectContext? {
+    private func createMainContext() -> NSManagedObjectContext {
         guard let wc = writingContext else {
             Log("Attempting to create `mainContext` before the persistent store coordinator is setup.")
             return nil

    
    
    private func removePersistentStore() throws {
        let lastStore = persistentStoreCoordinator?.persistentStores.last
        guard let store = lastStore else {
            throw CoreDataStackError.InvalidStore
        }
        
        do {
            try self.persistentStoreCoordinator?.removePersistentStore(store)
        }
        catch let error as NSError {
            Log("Unable to remove the persistent store with error: \(error.localizedDescription)")
            throw error
        }
    }
    
    private func removeDBFiles() throws {
//        if #available(iOS 9, *) {
//            try removeDBFilesiOS9()
//        } else {
//            try removeDBFilesiOS8()
//        }
    }
    
    @available(iOS 9.0, *)
    private func removeDBFilesiOS9() throws {
        let storeType = inMemoryStore ? NSInMemoryStoreType : NSSQLiteStoreType
        let options = [
            NSMigratePersistentStoresAutomaticallyOption : true,
            NSInferMappingModelAutomaticallyOption : true
        ]
        
        do {
            let url = containerURL.URLByAppendingPathComponent("\(modelName).sqlite")
            try persistentStoreCoordinator?.destroyPersistentStoreAtURL(url, withType: storeType, options: options)
        }
        catch let error as NSError {
            throw error

}




//MARK: - LifeCycle -
private extension CoreDataStack {
    
