Вопрос

I've been working to migrate an iCloud store to local storage in the application sandbox. The code looks like this (error handling code has been removed for clarity):

NSPersistentStore *iCloudStore = [_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:legacyStoreUrl options:options error:&error];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSURL *targetStoreUrl = [self localStorageUrl];
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
                       [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
                       [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption,
                       nil];

[_persistentStoreCoordinator migratePersistentStore:legacyStore toURL:targetStoreUrl options:options withType:NSSQLiteStoreType error:nil];

At this point we have successfully migrated the iCloud store to the new location in the application sandbox, but there is still data in iCloud and the old sqlite file in place... the following line deletes the sqlite file

[fileManager removeItemAtURL:legacyStoreUrl error:nil]

So after running all of this my file system and persistent stores are looking good as far as I can tell. The one missing bit is that the data that stored in iCloud is not deleted from iCloud (though it is no longer accessed by the app). What else needs to happen to programmatically delete the iCloud data? The apple iCloud docs mention deleting the transaction logs but I do not see any other files in my Documents folder that need cleaning up. Any help is much appreciated!

Update:

The iCloud store was originally set up using the following options:

NSURL *ubiquityContainerUrl = [fileManager URLForUbiquityContainerIdentifier:nil];
NSString* coreDataCloudContent = [[ubiquityContainerUrl path] stringByAppendingPathComponent:@"data"];



NSURL *coreDataUrl = [NSURL fileURLWithPath:coreDataCloudContent];

options = [NSDictionary dictionaryWithObjectsAndKeys:
               [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
               [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption,
               @"MyAppName.store", NSPersistentStoreUbiquitousContentNameKey,
               coreDataUrl, NSPersistentStoreUbiquitousContentURLKey,
               nil];
Это было полезно?

Решение 2

The transaction log folder will be at whatever location you set NSPersistentStoreUbiquitousContentURLKey to when you created the store in iCloud, and may be outside your Documents folder if that's where you chose to put it.

Log onto developer.icloud.com and see if anything has been stored at that point.

To delete, see my answer here for something I've used in the past:

Другие советы

I just discovered that Xcode allows you to reset the container using Xcode menu:

Debug->iCloud->Delete Container Contents

It is also helpful to be able to see the content online: https://developer.icloud.com/

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top