I cannot find an obvious way to detect deletion of a document that I control (I cache the list of documents that my application accesses).
On device1: When I delete a document, I call
[fileCoordinator coordinateWritingItemAtURL:fileURL options:NSFileCoordinatorWritingForDeleting
error:&err byAccessor:^(NSURL* writingURL) {
[fileManager removeItemAtURL:writingURL error:nil];
This works great on Device1, everything is in sync. On device2: I tried to rely on notifications NSMetadataQuery:
The initial list of files is in order. NSMetadataQueryDidFinishGatheringNotification
Adding / changing a document goes normally throughNSMetadataQueryDidUpdateNotification
When I delete a file on Device1, I get a strange result: the update happens in NSMetadataQueryDidUpdateNotificationwith all my documents (except for one of them) I'm not sure how I should find that the missing file was deleted or that the update notification was for this purpose
1: ?
, NSFilePresenter URL- iCloud:
- (NSURL *)iCloudDocumentsURL
{
return [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil] URLByAppendingPathComponent:@"Documents"];
}
NSFilePresenter URL-, , .
, , - - (void)presentedItemDidChange;
- (void)accommodatePresentedSubitemDeletionAtURL:(NSURL *)url completionHandler:(void (^)(NSError *errorOrNil))completionHandler
.
2: , ?