3

How may I use Core Data with multiple SQLite files?

Each file contains the same structures but the data is retrieved from different locations.
I want to be able to switch between these sqlite files at runtime based on application settings.

Cœur
39k25 gold badges207 silver badges282 bronze badges
asked Jun 12, 2011 at 16:53

1 Answer 1

2

Sure; just point the persistent store coordinator (NSPersistentStoreCoordinator) at the different databases, as needed.

Persistent store coordinators support addition and removal of stores. On removal, you want to make sure that there are no unsaved changes in memory (obviously) and, in general, that you will not be messing with any entities fetched from the removed store after removal.

Be careful, though, as Core Data does not support relationships where the objects at either end are in different stores.

answered Jun 12, 2011 at 18:18
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.