As we all know,
Core data is a amazing framework of
Cocoa let us easily working with data in iOS app. Today, I’m gonna write down something about an interested topic.
So topic is:
In case we want to switch to use physical storage location, you could imagine user want to use a fews of accounts, so we must save each storage file for each account. This will cause the app will load faster because it will show on screen the loaded data, and there will be some background fetches if needed.
Switching storage files
There is an sample that I wrote, and easy to understand. Beside mainly working with switching storage files, the way how we work with
UITableView included. This is a cool feature that Apple supplied. I give you a thumb up, Apple.
Sample project here
Back to the thread, switching between storage files is just a simple. We basically remove all the
persistenstoreCoordinator and re-add it from over. But first, don’t forget to save the state.
Here is it:
More over, I would like to suggest a valuable link to get fully understand about core data; This serials are quite easy to understand, and hope we could gain from it.
Beside that, Apple supplies a cool feature named Migration, that we can migrate between storage locations, and types of data. More details, it is nice to read this one;
But notice that, this one is not switching, this is in fact merge from old one with new one. So that carefully when working between them two.
Finally, if my project is good for you, don’t hesitate to give it a star. haha.