Domanda

I'm using NSMetadataQuery to detect if a document exists on my application iCloud container even if the file has not been downloaded locally.

Can NSFileCoordinator with an NSFilePresenter do the same ? Verifying that the file exists even though it is still not available locally ?

Update: I've been using for a while NSMetadataQuery to detect if a file exists in my ubiquity container. But at least testing on 10.8.2, it doesnt always work. I've been getting a lot of false negatives for existence of files.

I know others have been using I belive file coordinators. Does anyone have any opinion on this, or even better point me to an example on how to use them ?

È stato utile?

Soluzione

sending a message to NSFileCoordinator's coordinateReadingItemAtURL:options:error:byAccessor: method and doing what you want in the byAccessor block with its urlToUse (and checking error results by looking at the error) should work if you already have a valid URL to the item in iCloud you that you've been attempting to query for using NSMetadataQuery.

and you can create the NSFileCoordinator using initWithPresenter:nil, and it will work for all file-presenters.

so it seems it is sort of a matter of whether or not you already know the URL of the item you're searching for. using NSMetadataQuery is obviously going to be more handy in terms of creating an NSPredicate that will give you back an enumeration of the items in your iCloud ubiquity container when you don't already know their URLs.

(i can't help explain your false negatives, though i'd be inclined to check the NSPredicate you are creating for the file you are querying about, or i'd look to see if you have the notifications set up for both NSMetadataQueryDidUpdateNotification & NSMetadataQueryDidFinishGatheringNotification and that you haven't canceled them.)

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top