Correct way to detect deletion of documents in iCloud through devices?

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: , ?

+3
3

, iCloud, iCloud, , , .

, " ", NSMutableDictionary , , , "" . , , .

+3

tobinjim , NSMetadataQuery . , , RTFM .

, ​​iOS-. , , , iCloud :

    2012-06-25 13:15:12.343 app[19779:707] *** -[NSMutableIndexSet indexGreaterThanOrEqualToIndex:]: message sent to deallocated instance 0xdaae2c0
    (gdb) bt
    #0  0x31937870 in ___forwarding___ ()
    #1  0x31892650 in __forwarding_prep_0___ ()
    #2  0x373cc676 in __NSIndexSetEnumerate ()
    #3  0x373a1ee8 in -[NSIndexSet enumerateIndexesWithOptions:usingBlock:] ()
    #4  0x371c1f08 in -[LBQuery _processUpdates] ()
    #5  0x373571a6 in -[NSObject(NSThreadPerformAdditions) performSelector:onThread:withObject:waitUntilDone:modes:] ()
    #6  0x3737ffa4 in -[NSObject(NSThreadPerformAdditions) performSelector:onThread:withObject:waitUntilDone:] ()
    #7  0x371c2274 in -[LBQuery processUpdates] ()
    #8  0x373a88d6 in -[NSMetadataQuery _update] ()

, . IOS 6 . , NSMetadataQuery disable/enableUpdates, iCloud. . , NSMetadataQueryDidUpdateNotification , .

, NSMetadataQuery. , , NSZombie ( gdb, , lldb). , LBQuery, , .

NSMetadataQuery, , , iCloud .

+2

All Articles