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