From 06c91c66be2f259bc97b53f8216941e1d637b542 Mon Sep 17 00:00:00 2001 From: Paul Hudson Date: Wed, 17 Apr 2019 15:52:38 +0100 Subject: [PATCH] Added NotificationCenter post when keys have finished synchronization from iCloud. --- Sources/Zephyr.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sources/Zephyr.swift b/Sources/Zephyr.swift index 827b89f..882f671 100644 --- a/Sources/Zephyr.swift +++ b/Sources/Zephyr.swift @@ -7,6 +7,7 @@ // import Foundation +import UIKit /// Enumerates the Local (`UserDefaults`) and Remote (`NSUNSUbiquitousKeyValueStore`) data stores private enum ZephyrDataStore { @@ -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() @@ -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) } }