Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrating the local cloud store within the ...willLoadStoreIsCloud: method? #71

Open
NorbNorb opened this issue Aug 15, 2014 · 0 comments

Comments

@NorbNorb
Copy link

I'd like to check if an app update brought a new Core Data model version. If so, I'd like to migrate the cloud data, disable iCloud and work offline then. In particular:

  1. manually migrate the cloud store in ubiquityStoreManager:willLoadStoreIsCloud: to the new model version
  2. migrateCloudToLocal
  3. setCloudEnabled = NO (step 2 does this already automatically)

or in code:

- (void)ubiquityStoreManager:(UbiquityStoreManager *)manager willLoadStoreIsCloud:(BOOL)isCloudStore
{
  if (isCloudStore)
    {
        NSURL *cloudStoreURL = manager.URLForCloudStore;  // WRONG: gives ubiquity directory, not an sql file
        if ([self isMigrationNeededForSourceStoreURL:cloudStoreURL])
        {
            [self migrateStoreToCurrentModel:cloudStoreURL];
            [manager migrateCloudToLocal]; // This will also set iCloud disabled
        }
    }
}

My problem is that I cannot do the manual migration without knowing the URL to the persistent store file (sqlite). When ubiquityStoreManager:willLoadStoreIsCloud: is called there's no store coordinator which can tell me where the file is or which cloud store file to use.
Also, can I call migrateCloudToLocal within ubiquityStoreManager:willLoadStoreIsCloud:?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant