• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSMetadataQuery not handling scopes and predicates as expected
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSMetadataQuery not handling scopes and predicates as expected


  • Subject: NSMetadataQuery not handling scopes and predicates as expected
  • From: Ken Tozier <email@hidden>
  • Date: Sun, 3 Jul 2005 02:40:51 -0400

I managed to get some NSMetadataQuerys working but when attempting to use any of the scope constants, the query returns immediately with no results. Here's the various syntaxes I've tried:

NSMetadataQuery     *query        = [[NSMetadataQuery alloc] init];

This works
[query setSearchScopes: [NSArray arrayWithObjects: @"/System/ Library/", nil]];


These don't
[query setSearchScopes: [NSArray arrayWithObjects: NSMetadataQueryUserHomeScope, nil]];
[query setSearchScopes: [NSArray arrayWithObjects: @"NSMetadataQueryUserHomeScope", nil]];
[query setSearchScopes: [NSArray arrayWithObjects: NSMetadataQueryLocalComputerScope, nil]];
[query setSearchScopes: [NSArray arrayWithObjects: @"NSMetadataQueryLocalComputerScope", nil]];


Anyone have any success using the Apple defined constants? If so, any pointers on what I'm doing wrong?

Also, the following explicit path-based scope for the applications folder doesn't work either.
[query setSearchScopes: [NSArray arrayWithObjects: @"/Applications/", nil]];


I checked my Spotlight preferences and the Applications folder is one of the ones checked for indexing so I'm not sure why this isn't working. Any ideas?

Second problem is that some of the Spotlight meta-data keys don't seem to work. I defined several searches in the Finder and tried using the same keys the Finder uses like "kMDItemKind" without success.

The Finder displays this key's usage for a ".strings" file search in the "Get Info" panel like so:

(kMDItemKind = '*Strings File*'cd)

I've tried each of the following variations without success:

(kMDItemKind = '*Strings File*'cd)
result -> parser error which is expected as Apple specifically mentions this problem


(kMDItemKind = 'Strings File')
        result -> returns immediately with result count of zero

(kMDItemKind like[cd] '*Strings File*')
        result -> returns immediately with result count of zero

(kMDItemKind matches[cd] 'Strings File')
result -> parse error: "NSMatchesPredicateOperatorType NSComparisonPredicate not allowed to NSMetadataQuery"


(kMDItemKind matches 'Strings File')
result -> parse error: "NSMatchesPredicateOperatorType NSComparisonPredicate not allowed to NSMetadataQuery"


Since the kMDItemKind meta-data key is defined in the documentation and the Finder seems to use it for it's own spotlight searches, it seems to indicate that it's not a key exclusively for the use of Apple. Anyone successfully use this key? And if so, what syntax got it to work?

Thanks,

Ken
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSMetadataQuery not handling scopes and predicates as expected
      • From: Scott Anguish <email@hidden>
  • Prev by Date: HTML + CSS specs used in the WebKit for NSTextView
  • Next by Date: Re: Thwarting classdump, etc.
  • Previous by thread: Re: HTML + CSS specs used in the WebKit for NSTextView
  • Next by thread: Re: NSMetadataQuery not handling scopes and predicates as expected
  • Index(es):
    • Date
    • Thread