0

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?

Tom
  • 11
  • 4
  • Think this should be merged or closed as duplicate of http://stackoverflow.com/questions/6398546/searching-files-objective-c/6398568 – NSGod Jun 19 '11 at 01:38

1 Answers1

3

kMDItemSFName should be kMDItemFSName

Dave DeLong
  • 242,470
  • 58
  • 448
  • 498