Skip to content Skip to sidebar Skip to footer

Replacing Core Data Sqlite File While App Is Running, Data Does Not Update

I am developing a backup/restore system for my app in which the user can download a backed-up version of the core data store (sqlite file) and replace the currently-used data store

Solution 1:

What I think is tripping you up is the fact that even though you can set all your managed object contexts, store coordinators, and the like to nil, you still have to completely recreate every managed object in use that was based off those objects.

Your best bet is to do what you're doing now, but also find a way to destroy every Core Data object that you've used. Maybe you can pop your various view controllers down to the root and reload that controller from scratch, so that it uses your new Core Data stack? You'll lose a certain amount of user-friendliness (since they'll have to rebuild the view controller stack using the new data you've loaded), but you'll be sure that you've destroyed everything you need to.


Post a Comment for "Replacing Core Data Sqlite File While App Is Running, Data Does Not Update"