With iCloud, I set up a MetaDataQuery like so:
[query setSearchScopes:[NSArray arrayWithObject:NSMetadataQueryUbiquitousDocumentsScope]];
How do I set up the same MetaDataQuery for my normal local Documents Directory?
The following code will give me a static list of files in my directory – but I was looking for a more dynamic way so that I could use NSMetadataQueryDidUpdateNotification.
Here is my static code to look for files in my documentsDirectory:
NSArray* localDocuments = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:
[self documentsDirectory] error:nil];
NSArray *onlyPQs = [localDocuments filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self ENDSWITH '.pq'"]];
NSLog(@"local file count: %i", [onlyPQs count]);
for (int i=0; i < [onlyPQs count]; i++) {
NSLog(@"LOCAL:%@", [onlyPQs objectAtIndex:i]);
}
I’ve been looking for an answer to this question and, according to the documentation (Searching iCloud and the Desktop), it’s not possible:
On Mac OS X three additional scopes are defined:
NSMetadataQueryUserHomeScope,NSMetadataQueryLocalComputerScopeandNSMetadataQueryNetworkScopewhich can be used to achieve this.