Skip to content

Commit

Permalink
🐛 iCloud同期が正常にリロードできない問題を修正
Browse files Browse the repository at this point in the history
  • Loading branch information
tasuwo committed Mar 14, 2022
1 parent 463c6e3 commit d88b1c0
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ public extension PersistentContainer {
let isiCloudSyncEnabled = (self.author == .app && isiCloudSyncSettingEnabled)

let container = Self.makeContainer(forAppBundle: self.appBundle, author: self.author, isiCloudSyncEnabled: isiCloudSyncEnabled)

// iCloud同期中のStoreが残っていると新たなiCloud同期Storeをロードしようとした際に失敗してしまうので、
// このタイミングで明示的に削除する
self._persistentContainer.value.persistentStoreCoordinator.persistentStores.forEach {
try? self._persistentContainer.value.persistentStoreCoordinator.remove($0)
}

self._persistentContainer.send(container)
self.isiCloudSyncEnabled = isiCloudSyncEnabled

Expand Down

0 comments on commit d88b1c0

Please sign in to comment.