1

someone please explain when should I increase the xcdatamodeld version? I google a lot, there are all about migration, but when should I increase the version?

Currently if I make change in my xcdatamodeld such as add entity or add attribute, I will recreate nsmanagedobject subclass. But I am not sure what situation that I have to increase the xcdatamodeld version.Please someone explain it. Thanks!

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Magrider
  • 51
  • 6
  • After you publish your app on App Store, if you make some changes to your data model, you need to increase the version. So that you can do proper data migration between different versions. – Eric Qian Oct 10 '16 at 22:18

1 Answers1

1

I think of it as a tool for helping users of my app migrate from the previous data model to the new data model. So I don't bump the version up unless I have to "release" it in some fashion (app store, or internal testers). Even then, if I have a small group of testers, I may just tell them to delete and reinstall so that I don't have to muck with it.

If a user with the old data model installs your app update with a new data model, they will crash unless you instruct the data model to "migrate".

ghostatron
  • 2,620
  • 23
  • 27
  • Thanks for the reply. What kind of change will make the app crash? It seems fine even though I made some changes and recreate the nsmanagedobject subclass. – Magrider Oct 11 '16 at 00:24
  • Anything that changes the model will cause a crash when the moc with the changed model tries to open a store that was create with the previous model. This means adding new entities, adding attributes or relations, or changing attribute types. Changing the name of attributes, entities or relations is also sufficient to cause a crash. Changing the subclass is fine, because that doesn't affect the structure of the model. – Rudedog Oct 12 '16 at 01:49