How to detect changes in iCloud Key/Value Data

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];




Jay is the CEO and founder of WP Hosting, a boutique style managed WordPress hosting and support service. He has been working with Plesk since version 9 and is a qualified Parallels Automation Professional. In his spare time he likes to develop iOS apps and WordPress plugins, or draw on tablet devices. He blogs about his coding journey at http://wpguru.co.uk and http://pinkstone.co.uk.