Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maintaining Core Data in Future App Versions

I am currently creating an app that requires a large amount of user generated information to be stored in Core Data. When I release a new update of this app, I want to make sure that these users do not lose all of this data.

When I delete my current version from my iPhone, all of the Core Data disappears- will this happen when I create a new update version- does updating cause all of the Core Data to be deleted as the app is replaced? If so, what do I have to do to preserve the data?

I will not be changing my Core Data model between updates, if that changes anything...

like image 908
user1388795 Avatar asked Aug 10 '12 00:08

user1388795


People also ask

When should you save context in Core Data?

save context at the end of every change. save context only on app's exit (like in Apple's samples) save context on app's exit, going to background or becoming not active (incoming phone call for example) add timer to save context from time to time if it has any changes.

What is persistence in Core Data?

Object graph management: Core Data works with defined objects, and core data keeps track of these objects and their relationships with each other. Persistence: Data can be retrieved, in this case, either from the device or from a network location. SQLite: One of the potential data stores that Core Data can use.

What should Core Data be used for?

Use Core Data to save your application's permanent data for offline use, to cache temporary data, and to add undo functionality to your app on a single device. To sync data across multiple devices in a single iCloud account, Core Data automatically mirrors your schema to a CloudKit container.

Where does Core Data store Data?

The persistent store should be located in the AppData > Library > Application Support directory.


1 Answers

Simple question - simple answer, the Core Data is backed up to iTunes/iCloud as part of the iPhone backup, and the users data is also persisted between updates.

You can optionally include the core data to be included in an iCloud sync, this means that even deleting the app and reinstalling it, the data will persist.

If you change your model, you are reasonable for mapping the old scheme to the new one, the data is then transferred via this mapping model when the new update occurs, the previous schemes data will get transferred into the new core data scheme.

Core Data versioning: https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CoreDataVersioning/CoreDataVersioning.pdf

like image 74
Daniel Avatar answered Nov 03 '22 20:11

Daniel