With iCloud, I configured MetaDataQuery like this:
[query setSearchScopes:[NSArray arrayWithObject:NSMetadataQueryUbiquitousDocumentsScope]]
How to configure the same MetaDataQuery for my regular local document directory?
The following code will provide me with a static list of files in my directory, but I was looking for a more dynamic way to use NSMetadataQueryDidUpdateNotification .
Here is my static code for finding files in my documents. Directory:
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]); }
source share