Thanks for this great book and for updating it every year!
I would like to make a request if I may: Can you please add a section or chapter about creating backups and restoring it for the data stored locally by using Core Data? What are the best practices for this rather common need? How can we test and be sure that backup and restore operations are successful? Can you please demonstrate with a sample project?
Here are some useful links about this:
@ertugrul Thanks very much for your question (and AWESOME handle!)
You might want to check out the new chapter on NSPersistentCloudKitContainer in the current edition. This allows you to store data to iCloud which means you can backup the data from your app, or share that data with others users if necessary. This is one creative solution that can be used with Core Data.
That being said, what a lot of apps do is “preload” data that the app needs to get started which occurs on the very first install. If there is important data that needs to be stored, in some cases, UserDefaults is used. The reason why you wouldn’t necessarily use Core Data to back up the data on your app is because it is part of the app itself, which means if you delete the app from your device, any data stored in Core Data is also deleted. This is why using the NSPersistentCloudKitContainer is such a valuable resource
Options such as storing the underlying .sqlite file is definitely option, but as a solution, it isn’t necessarily the best choice now that saving to iCloud is available. Definitely something to look into further.
I hope this helps!
All the best.
This topic was automatically closed after 166 days. New replies are no longer allowed.