STORING KEY-VALUE DATA IN ICLOUD
In Chapter 9, you learned about the use of the NSUserDefaults class to save user's preferences data in the Settings application. You do so via the use of key-value pairs, which can be simple data types like numbers, strings, arrays, and so on. However, data stored using the NSUserDefaults class is available only to the application on that particular device; if you have the same application on multiple devices, these values cannot be shared. Imagine you are writing an eBook reader application that runs on both the iPhone and iPad platforms. Users may install your application on multiple devices. When they stop reading at a particular page on their iPhone, they might want to continue from where they left off by reading it on their iPad later. In this case, there must be a way for the application on both devices to retrieve the user's last page number. Of course, you could devise your own server solution whereby the application can sync the information back to the server, but that would mean you have to write an additional application (such as JSON web services, or a socket server).
Fortunately, besides saving user documents, you can use iCloud to save small chunks of information so that the same application running on different devices can share them. It does impose some restrictions, most of which should not be a major problem for most applications. Using iCloud, you can save key-value data with the following restrictions:
- The maximum amount of ...