views:

19

answers:

1

I have an application that will play a series of radio stations by choosing them from a drop down menu. Ideally I'd like to add some code, so that a spotlight search that would return any of the items in the dropdown and open the application as if you did this from within the application itself.

The spotlight documentation gives no clues to whether this is possible, apart from some old posts I found about creating hidden files to be indexed.

Any clues?

A: 

How are your individual stations stored / represented internally? Spotlight is one-file-one-search-result. Apps with a single library DB or similar traditionally export those items in a subfolder of the ~/Library/Caches folder. You'd write one spotlight "stub" file per item you want to be searchable. This "stub" file will have its own separate extension/doctype (that's still openable by your app) and that's what you'll base your Spotlight importer on.

Precedent: AddressBook.app.

For example, in one of my apps, there's a central (non-document-based) transcript library database. I wanted users to be able to search individual transcripts and have them show up as separate results in Spotlight. The only way around this was for my application to create and maintain a disposable collection of ".transcriptstub" files that held a searchable text representation.

I say "disposable" because things in ../Caches are meant to be easily recreated by your application if missing. I update them if needed at application launch (as a separate NSOperation so as to prevent long launches), and each individual one as it's modified during runtime.

When the application is handed one of these stubs to open, it uses some identifier in the file (a UUID perhaps?) and looks for that in the database. If there's a match, it selects that item in the UI.

Joshua Nozzi
Thanks for this Joshua, you have managed to explain it far better than any of the Apple documentation.
Duncan Robertson