prevent deadlock on when DataStack gets deallocated

This commit is contained in:
John Rommel Estropia committed 2016-04-01 01:28:39 +09:00
1 parent 0b24072259
commit 44cfbebedb
1 file changed
+9 -2
+9 -2
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)
}
}
}
}
}