I am quite happy with versioning and database migration. I simply have a database of running trails that I add information (more trails) on a regular basis. I want to ship these new trails on version upgrades so the users can have an ever growing list of tra开发者_JS百科ils to run. For example i add say 10 trails per month to the app that users who have bought the app need to get when they download the new version.
I was wondering how best to do this and cant find reference to it anywhere. Should you hardcode the adding of new information in say the ApplicationdidfinishLaunching method for example or is there a way to compare databases or not have to rely on hard coding of data which could lead to mistakes.
I could ask the users to delete their app of the phone and reinstall the new one but that is rather cumbersome and the kind of thing microsoft would do.
Thanks for your help in advance.
Willow
AFAIK there's no automation for this kind of task. I do it in this way (in applicationDidFinishLaunching):
- compare lastAppVersion value from user defaults
- if not set or lastAppVersion == current application version, do nothing
- if lastAppVersion != current application version, migrate data from lastAppVersion to current application version
- store current application version to lastAppVersion (user defaults)
It can help me to do some stuff within updates if there's no automation for a task.
If it takes longer, I do this in custom splash screen view controller to let user know what's happening or at least to show some progress bar.
精彩评论