prevent deadlock on when DataStack gets deallocated

This commit is contained in:
John Rommel Estropia
2016-04-01 01:28:39 +09:00
parent 0b24072259
commit 44cfbebedb

View File

@@ -399,9 +399,16 @@ public final class DataStack {
deinit {
for store in self.coordinator.persistentStores {
let coordinator = self.coordinator
coordinator.performAsynchronously {
_ = try? self.coordinator.removePersistentStore(store)
withExtendedLifetime(coordinator) { coordinator in
coordinator.persistentStores.forEach {
_ = try? coordinator.removePersistentStore($0)
}
}
}
}
}