14 March 2006

Spotlight's NSMetaDataQuery

Do you ever try to use an API from any particular programming language and after a while you just give up because it just does not seem to work? Well i recently ran into something similar with the Cocoa NSMetadataQuery class.

DTMetaData Cocoa Classes

I was playing around with Cocoa Spotlight classes and i started trying to use the setPredicate: message. The documentation on Apples website says we can use the same kind of query string as we when using a MDQueryRef, but it just didn't seem to work. After messing around for an hour, i finally decided to post a question to the cocoa-dev mailling list. The responses i got were pretty much what i expected - NSMetaDataQuery still has a few bugs and the NSPredicate passed to it does not get parsed correctly on all occasions.

With that said, I set out to write my own Spotlight query classes. It took about a half hour and they just feel like a bit more love and care went into them then Apple's.

Source code available below.

Download DTMetaData classes (5KB)

Comments

No comments yet

Add Comment

:

:
: