Tag Archives: nspredicate

ParseKit (and Clipstart search)

The first couple versions of “Clipstart”:http://www.riverfold.com/software/clipstart/ had a very basic search feature. You could enter keywords and it would search filenames, tags, and video titles. You could also enter special terms such as tags=christmas or imported=today, but you couldn’t mix and match different terms together.

When I started working on a more advanced search parser, I realized that I was about to write a bunch of code that surely someone had already generalized and shared with the world. Tada! “ParseKit”:http://parsekit.com/ by Todd Ditchendorf is that framework.

Clipstart 1.3 now supports these kind of searches:

christmas and (@julian or @kids)


(uploaded=no and flagged=yes) or (date=2010 and @vacation)

I use ParseKit’s tokenizer to take these apart and then I translate to SQL myself for SQLite. New in 1.3, Clipstart also allows saving any search as a “smart tag” for quick access. I’m very happy with how well it’s working.

Why not use “NSPredicate”:http://developer.apple.com/mac/library/documentation/cocoa/reference/Foundation/Classes/NSPredicate_Class/Reference/NSPredicate.html and friends? I wanted more control over the parser, for example for the @kids shorthand for tags. Eventually I’ll have a more traditional NSPredicateEditor-like UI for managing searches, but I find that text input is a much quicker way to find things in my video library.