How to detect changes in iCloud Key/Value Data

- by

Now that we can read from and write to iCloud, how will we know when another device may have written new data?

We’ll do this by adding an observer and listening to a special message iCloud transmits every time new data is available. The message has the catchy title NSUbiquitousKeyValueStoreDidChangeExternallyNotification.

Here’s how we can setup such an observer. This calls a method (newCloudData) in which you can react to the changes:

// setup an observer
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(newCloudData) name:NSUbiquitousKeyValueStoreDidChangeExternallyNotification object:nil];


If you enjoy my content, please consider supporting me on Ko-fi. In return you can browse this whole site without any pesky ads! More details here.

Leave a Comment!

This site uses Akismet to reduce spam. Learn how your comment data is processed.