Chapter 12. Data persistence in iCloud
This chapter covers
- Storing user preferences in iCloud
- Storing data in iCloud using CloudKit
In this chapter, you’ll take storing data to the next level—iCloud.
Until now, you’ve only stored user defaults locally on the device. What happens if the user opens your app on another device they own?
In this chapter, you’ll explore iCloud, a convenient cloud data storage service provided by Apple, which can be used by developers to automatically share data and give your user the same experience between multiple devices. You’ll look at storing discrete values such as user preferences in iCloud using the ubiquitous key-value store. You’ll also explore CloudKit, an essential framework for storing structured data in iCloud.
Along the way, you’ll encounter additional concepts:
- Concurrent programming in iOS
- Indicating background tasks
- Displaying alerts
- Refreshing a table view
- Receiving remote notifications
Note
If you haven’t enrolled in the Apple Developer Program yet, be aware that membership is necessary to use iCloud. If you need to enroll, you’ll want to click here and follow Apple’s instructions: https://developer.apple.com/programs/enroll/. We’ll go into this process in more detail in chapter 16. If you’re not ready to enroll, you might want to skip this chapter for now.
In this chapter, you’ll store book data and user preference data for the Bookcase app in iCloud.