             NSLog("Unresolved error \(wrappedError), \(wrappedError.userInfo)")
             abort()
         }
-        
+
         return coordinator
     }()
 
     private lazy var storeURL: NSURL = self.applicationDocumentsDirectory().URLByAppendingPathComponent(self.modelName + ".sqlite")
-    
+
     private init(modelName: String) {
         self.modelName = modelName
         NSNotificationCenter.defaultCenter().addObserver(self, selector: "managedObjectContextDidSaveNotification:", name: NSManagedObjectContextDidSaveNotification, object: nil)
     }
-    
+
     private func applicationDocumentsDirectory() -> NSURL! {
         let urls = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)
         return urls[urls.count - 1]
     }
-    
+
     //MARK: Support for managed object context access from different threads
-    
+
     func currentContext() -> NSManagedObjectContext! {
         if NSThread.isMainThread() {
             return self.managedObjectContext

            var dict = [String: AnyObject]()
            dict[NSLocalizedDescriptionKey] = "Failed to initialize the application's saved data"
            dict[NSLocalizedFailureReasonErrorKey] = failureReason
            
            dict[NSUnderlyingErrorKey] = error as NSError
            let wrappedError = NSError(domain: "YOUR_ERROR_DOMAIN", code: 9999, userInfo: dict)
            // TODO: Replace this with code to handle the error appropriately.

            }
            return;
        }

        // Merge thread-related context into the main context
        self.managedObjectContext.mergeChangesFromContextDidSaveNotification(notification)
    }

    public func resetDatabase() throws {
        //TODO: If the persistentStoreCoordinator had been already created, it must also be reset
        let path = storeURL.path!
        guard NSFileManager.defaultManager().fileExistsAtPath(path) else { return }
        try NSFileManager.defaultManager().removeItemAtURL(storeURL)
        try NSFileManager.defaultManager().createFileAtPath(path, contents: nil, attributes: nil)
    }
}
