I have Core Data working in my app. So, I fetch an XML file, parse the data into model objects and insert them into core data. They are saved in the persistent store and I
swift version of @Nicolas Manzini answer:
if let psc = self.managedObjectContext?.persistentStoreCoordinator{
if let store = psc.persistentStores.last as? NSPersistentStore{
let storeUrl = psc.URLForPersistentStore(store)
self.managedObjectContext?.performBlockAndWait(){
self.managedObjectContext?.reset()
var error:NSError?
if psc.removePersistentStore(store, error: &error){
NSFileManager.defaultManager().removeItemAtURL(storeUrl, error: &error)
psc.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: storeUrl, options: nil, error: &error)
}
}
}
}