PrefsInCloud

Last Revision:
Version 1.0, 2011-11-29
A simple iOS iPhone application that demonstrates how to use iCloud key-value store to share a single piece of data between two devices.
Build Requirements:
iOS 5.0 SDK or later
Runtime Requirements:
iOS 5.0 or later, an iCloud account

A simple iOS iPhone application that demonstrates how to use iCloud key-value store to share a single piece of data, its background color, with the same app on other iOS devices. It uses NSUbiquitousKeyValueStore to achieve this by storing a simple NSInteger representing a chosen color index.

The user changes the background color of the app by choosing between 4 known colors.  Tap the 'i' button and pick the color you want.  After tapping "Done", this key-value store (number 0 to 3) is uploaded to iCloud.  Any device running the same app will be notified to match that specific background color.

It then uses NSNotificationCenter and iCloud's NSUbiquitousKeyValueStoreDidChangeExternallyNotification to detect for value changes in the cloud.


Did this document help you? Yes It's good, but... Not helpful...