Creating Backups

Creating a backup is easy now that DropboxHelper is in place. Before a backup is taken, all contexts should be saved to ensure that the latest data is persisted. The contexts will be saved in an order appropriate to their hierarchy. In other words, the child contexts will be saved before their parents to ensure changes are in the parent before the parent is saved. In your own projects you may wish to introduce non-nil error handling for these saves as opposed to the approach used in the upcoming code.

The procedure to create a backup involves setting an appropriate backup ZIP filename, creating the backup ZIP, and then moving it to Dropbox. There will also be a small amount of logic to deal with existing files. The process will ...

Get Learning Core Data for iOS: A Hands-On Guide to Building Core Data Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.