Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Introduction to Core Data with Swift 2 Understanding the Core Data Stack What is Core Data?

How do I migrate User Defaults in order to prevent crashing when installing new versions of my app?

Hi,

I have an app on the app store. I need to update the version after adding some changes. I'm finding that the app will crash on loading when I install the new version over the old---but the crash doesn't happen if I uninstall the previous version first (which clears all persisted data). I assume this is a pretty common problem.

The only piece of persisted data I use is a "on-boarding complete" boolean, letting the app know if the user has already gone through the on-boarding pages.

So, if everything above sounds right, my question is: How do I migrate the User Defaults from one version to the next so that the App doesn't crash when users download new versions from the App Store?

I'd appreciate any help / guidance.