PrefsInCloud

Last Revision:
Version 1.2, 2013-10-08
Now uses AutoLayout, fixed resizing issues with front and back views.
(Full Revision History)
Build Requirements:
Xcode 5.0, iOS 6.0 SDK or later
Runtime Requirements:
iOS 6.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.