Skip to content
This repository has been archived by the owner on Aug 29, 2024. It is now read-only.

Commit

Permalink
Added NotificationCenter post when keys have finished synchronization…
Browse files Browse the repository at this point in the history
… from iCloud. (#36)
  • Loading branch information
twostraws authored and ArtSabintsev committed Apr 19, 2019
1 parent a535ad1 commit 6bbef91
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Sources/Zephyr.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import Foundation
import UIKit

/// Enumerates the Local (`UserDefaults`) and Remote (`NSUNSUbiquitousKeyValueStore`) data stores
private enum ZephyrDataStore {
Expand All @@ -26,6 +27,9 @@ public final class Zephyr: NSObject {
/// If **true**, then `NSUbiquitousKeyValueStore.synchronize()` will be called immediately after any change is made.
public static var syncUbiquitousKeyValueStoreOnChange = true

/// A string containing the notification name that will be psoted when Zephyr receives updated data from iCloud
public static let keysDidChangeOnCloudNotification = Notification.Name("ZephyrKeysDidChangeOnCloudNotification")

/// The singleton for Zephyr.
private static let shared = Zephyr()

Expand Down Expand Up @@ -435,6 +439,9 @@ extension Zephyr {
for key in monitoredKeys where cloudKeys.contains(key) {
syncSpecificKeys(keys: [key], dataStore: .remote)
}

// Notify any observers that we have finished synchronizing an update from iCloud
NotificationCenter.default.post(name: Zephyr.keysDidChangeOnCloudNotification, object: nil)
}
}

Expand Down

0 comments on commit 6bbef91

Please sign in to comment.