O'Reilly logo

Swift Development with Cocoa by Tim Nugent, Jonathon Manning, Paris Buttfield-Addison

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

Chapter 10. iCloud and Data Storage

Unless your application is a trivial one, it will need to work with data at some point. This data could be as simple as a list of high scores that the user has achieved, or as complex as a multimedia document like a presentation.

This information needs to be accessible to other parts of your application, such as the controller objects, so that work can be done on it. The information needs to be stored somewhere—either in memory, on disk, or on the network.

OS X and iOS provide tools for storing information on disk and on the network. One of the more recent additions to the APIs available to developers is iCloud, a network-based storage system that is designed to allow users to keep the same information on all their devices, without having to do any work to enable this.

In this chapter, you will learn how to work with the filesystem to store your information on disk, and how to store simple data in the built-in user preferences database. You’ll also learn how to work with iCloud storage to store data and files in the cloud. Finally, you’ll learn how the sandbox works on OS X, and how to use security-scoped bookmarks to allow your application to access data outside its sandbox across multiple launches.

Note

While iCloud provides the means for storing files and folders in the cloud, you also need to know how to present documents to the user. This chapter only covers the mechanics of storing the data; to learn more about how to write a document-based application ...

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