Reputation: 11
I am looking for a class to use from the Cocoa API to perform a Spotlight search on the entire system. I looked at NSMetadataQuery
and believe this is the class for this, however I don't understanding how to do this; primarily NSPredicate
. I would like to search the system for a file named "test123.html" for example and get its full path. Examples are greatly appreciated. My code:
NSMetadataQuery *q = [[NSMetadataQuery alloc] init];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"kMDItemSFName == %@", @"test123456.png"];
[q setPredicate:predicate];
[q startQuery];
while ([q isGathering]) {
NSLog(@"%lu", [q resultCount]);
}
[q stopQuery];
This returns 0 results. Why?
Upvotes: 0
Views: 1579