Question

For an iOS application, I'm investigating how to sync user data through iCloud. As the data is very small, I currently think of using iCloud's key-value store (NSUbiquitousKeyValueStore).

I have a few questions regarding the internal working of NSUbiquitousKeyValueStore for which I couldn't find answers in the documentation:

  • After a change (NSUbiquitousKeyValueStoreDidChangeExternallyNotification), can I assume that all key-value pairs are up-to-date? Or is it possible that key A is up-to-date, but key B is not yet updated?
  • If I update an NSArray or NSDictionary in the store, is the whole thing uploaded and downloaded during synchronization, or does iCloud somehow only synchronize the changed values in the array/dictionary?
  • Does the size of a changed value (like a changed NSNumber of a few bytes vs. a changed NSArray of 50KB) affect the moment iOS chooses to perform synchronization?

Hopefully someone experienced with NSUbiquitousKeyValueStore has answers to these questions!

Was it helpful?

Solution

  • After a change (NSUbiquitousKeyValueStoreDidChangeExternallyNotification), can I assume that all key-value pairs are up-to-date? Or is it possible that key A is up-to-date, but key B is not yet updated?

Not sure what you are asking for here. When you receive this notification, the store already contains the new values it downloaded from the cloud.

  • If I update an NSArray or NSDictionary in the store, is the whole thing uploaded and downloaded during synchronization, or does iCloud somehow only synchronize the changed values in the array/dictionary?

The whole value is uploaded/downloaded.

  • Does the size of a changed value (like a changed NSNumber of a few bytes vs. a changed NSArray of 50KB) affect the moment iOS chooses to perform synchronization?

No. The frequency of your updates is essentially what affects the moment iOS chooses to push your change. In short, it might to delay the sync if you are doing it too often.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top