I work with documents in the cloud ... * Add a document to the cloud * Delete this document from the cloud * Somehow this document appears in a few seconds.
Here are the details:
I am creating an instance of a UIDocument like this
NSURL *ubiq = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil];
NSURL *ubiquitousPackage = [[ubiq URLByAppendingPathComponent:@"Documents"] URLByAppendingPathComponent:@"somenewfilename"];
MyDoc* docTemp = [[MyDoc alloc] initWithFileURL:ubiquitousPackage];
docTemp.mapContent = [NSString stringWithString:self.currentdocument.mapContent];
[docTemp saveToURL:[docTemp fileURL]
forSaveOperation:UIDocumentSaveForCreating
completionHandler:^(BOOL success) {
if (success) {
DLog(@"New document %@ saved/added: %@", newFilename, docTemp);
}
else {
DLog(@"Failed saving new document: %@", newFilename);
}
[docTemp release];
}];
Then delete it later as follows:
NSURL* fileURL = self.currentdocument.fileURL;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) {
NSFileCoordinator* fileCoordinator = [[NSFileCoordinator alloc] initWithFilePresenter:nil];
NSError* error = nil;
[fileCoordinator coordinateWritingItemAtURL:fileURL options:NSFileCoordinatorWritingForDeleting error:&error byAccessor:^(NSURL* writingURL) {
if (error != nil) {
DLog(@"Error with %@! %@", fileURL, error);
return;
}
DLog(@"Got writingURL: %@", writingURL);
NSFileManager* fileManager = [[NSFileManager alloc] init];
if ([fileManager removeItemAtURL:writingURL error:nil]) {
DLog(@"Deleted %@!", writingURL);
}
else {
DLog(@"ERROR Failed deleting %@!", self.currentdocument);
}
[fileManager release];
[fileCoordinator release];
}];
});
Now, despite the above, it seems that the file has been deleted for the (short) message, but in some cases the deleted document reappears in the cloud after a few seconds. (I can verify this through iCloud settings on another device or through a request that sends update notifications). Only in some cases does the file remain deleted. What's happening?
, Settings- > iCloud . . ? ?