prevent deadlock on when DataStack gets deallocated

This commit is contained in:
John Rommel Estropia
2016-03-31 00:04:17 +09:00
parent b529735269
commit 28b7ba01dc

View File

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