I can't seem to find any reliable documentation that explains the correct procedure for deleting a UIManagedDocument, and in particular one where the iCloud options have been turned ON.
I understand that this option would delete the file at this fileURL. And this would appear to be fine if iCloud is not being used.
[[NSFileManager defaultManager] removeItemAtURL:fileURL error:&error];
If iCloud is being used then CoreData creates files all over the place, including in /Document/CoreDataUbiquitySupport and in the iCloud /CoreData folder. So in this case is it up to me to call removeUbiquitousContentAndPersistentStoreAtURL
for each store in the UIManagedDocument
prior to calling [NSFileManager removeItemAtURL]
. If so is this documented somewhere ?
[NSPersistentStoreCoordinator removeUbiquitousContentAndPersistentStoreAtURL:storeURL
options:@{NSPersistentStoreUbiquitousContentNameKey:fileName,
NSMigratePersistentStoresAutomaticallyOption:@YES,
NSInferMappingModelAutomaticallyOption:@YES,
NSSQLitePragmasOption:@{ @"journal_mode" : @"DELETE" }}
error:&error];