Note that there are some explanatory texts on larger screens.

plurals
  1. POiCloud files keep reappearing after deleting
    text
    copied!<p>I have the following setup: My app writes UIDocument instances to iCloud. The files get synced and everything works fine. But when I try to delete them they keep reappearing. Before I delete the files I close them. Here is the code that deletes the files:</p> <pre><code>- (void)deleteDocumentWithName:(NSString*)name completion:(void (^)(BOOL success))completion { [self stopQuery]; NSURL* toDelete = [self URLForFileWithName:name]; UIDocument* doc = [[UIDocument alloc] initWithFileURL:toDelete]; void (^deleteDocument)() = ^() { // Wrap in file coordinator dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) { NSFileCoordinator* fileCoordinator = [[NSFileCoordinator alloc] initWithFilePresenter:nil]; [fileCoordinator coordinateWritingItemAtURL:toDelete options:NSFileCoordinatorWritingForDeleting error:nil byAccessor:^(NSURL* writingURL) { // Simple delete to start NSFileManager* fileManager = [[NSFileManager alloc] init]; NSError* error = nil; [fileManager removeItemAtURL:writingURL error:&amp;error]; if (error) { LogError(@"%s - error while deleting file: %@", __PRETTY_FUNCTION__, error); } dispatch_async(dispatch_get_main_queue(), ^{ [_files removeObject:toDelete]; if (completion) { completion((error == nil)); } [self startQuery]; }); }]; }); }; if (doc) { if (doc.documentState == UIDocumentStateNormal) { [doc closeWithCompletionHandler:^(BOOL success) { if (success) { deleteDocument(); } else { if (completion) { completion(NO); } } }]; } else { deleteDocument(); } } } </code></pre> <p>After this method was executed I get several NSMetadataQueryDidFinishGatheringNotifications. First it does not contain the deleted file. Then another NSMetadataQueryDidFinishGatheringNotification gets caught and it contains the deleted file again.</p> <p>I can't find the reason for this. Any help is appreciated.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload