O'Reilly logo

iOS 5 Programming Cookbook by Vandad Nahavandipoor

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

17.5. Storing User Documents in iCloud

Problem

You want to allow the users of your app to create documents in your app and you want to have those documents present on all devices that the user owns.

Solution

Use UIDocument.

Discussion

Although a user can have many files of different types stored on her device by different apps, each app has to be considerate of the amount of data that it puts in the user’s iCloud storage. Therefore, only the data that the user generates while using your app might need to be saved to the user’s iCloud storage space. For instance, if you are creating a web-browser app, the data that your browser app caches on disk on the device should not be stored on the cloud. Why? Because that data was not generated by the user. Your app simply was trying to give a better user experience by caching the data so that the next time it accesses the same series of web pages, the pages load faster. If you look at it from the user’s perspective, she didn’t really ask you to cache the data. What’s even worse is that your app is now using the user’s iCloud storage (for which she might have probably paid) to store cached data. That is simply wrong. You must ask the user what data your app is storing on the cloud, and if she doesn’t allow you to use her cloud storage space, you should avoid using that space and just store the data locally in your app’s sandbox.

One of the most confusing facts about iCloud is how you, as the programmer, will need to manage the data stored in the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required