drewmccormack / ensembles

A synchronization framework for Core Data.
MIT License
1.63k stars 131 forks source link

Multiple accounts/database #177

Closed cflorion closed 10 years ago

cflorion commented 10 years ago

My app can switch between different accounts. I don't want accounts to interfere with each other and I absolutely don't want accounts to sync via Ensembles (confidentiality).

So each account has it's own store and sqlite file. I setup my Core Data stack with MagicalRecord like this:

[MagicalRecord setupCoreDataStackWithAutoMigratingSqliteStoreNamed:[NSString stringWithFormat:@"database_%@.sqlite", accountID];

Then I setup my Ensemble with its own Ensemble identifier like this:

self.ensemble = [[CDEPersistentStoreEnsemble alloc] initWithEnsembleIdentifier:[NSString stringWithFormat:@"MainStore_%@",accountID
                                                                persistentStoreURL:self.storeURL
                                                             managedObjectModelURL:self.modelURL
                                                                   cloudFileSystem:self.cloudFileSystem];

Is this the way to handle multiple accounts ?