Skip to content

Commit

Permalink
Merge pull request #423 from 3lvis/fix/persistent-store-not-recreating
Browse files Browse the repository at this point in the history
Rollback to old way of restoring persistent store
  • Loading branch information
3lvis authored Sep 20, 2017
2 parents 9c52cfc + 5327ea6 commit 693562b
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions Source/DataStack/DataStack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -299,22 +299,9 @@ import CoreData
self.persistentStoreCoordinator.performAndWait {
for store in self.persistentStoreCoordinator.persistentStores {
guard let storeURL = store.url else { continue }

do {
if #available(iOS 9, OSX 10.11, tvOS 9, watchOS 2, *) {
try self.persistentStoreCoordinator.destroyPersistentStore(at: storeURL, ofType: self.storeType.type, options: store.options)
try! self.persistentStoreCoordinator.addPersistentStore(storeType: self.storeType, bundle: self.modelBundle, modelName: self.modelName, storeName: self.storeName, containerURL: self.containerURL)
} else {
try! self.oldDrop(storeURL: storeURL)
}

DispatchQueue.main.async {
completion?(nil)
}
} catch let error as NSError {
DispatchQueue.main.async {
completion?(NSError(info: "Failed dropping the data stack.", previousError: error))
}
try! self.oldDrop(storeURL: storeURL)
DispatchQueue.main.async {
completion?(nil)
}
}
}
Expand Down

0 comments on commit 693562b

Please sign in to comment.