views:

258

answers:

1

I would like to modify a Spotlight metadata attribute of a file within my application (i.e. not in a Spotlight importer) but I can't find any API for doing so. Is it possible? Pointers to the relevant docs would be ideal.

In case it's helpful, here's my use case:

I want to store a reference to a file system path in a Core Data store. Ideally, I should be able to find the file even if is moved, potentially across mounted volumes. My understanding is that an archived FSRef or AliasRecord will not do the trick because they are not invariant wrt to moves across mounted volumes. So my plan was to store a URL and also to add a UUID (also stored in the data store) to the file's Spotlight metadata so that I could perform a Spotlight query for that UUID if the URL no longer pointed to the file when the app goes back to look for the file.

+1  A: 

After further research, using Spotlight is not the best solution for the use case. The AliasRecord is a better persistent storage for a file. It automatically tracks moves/renames/etc. You can read more about AliasRecords here. Chris Hansen has written an Objective-C wrapper for AliasRecords, BDAlias. It's currently available from the rentzsch.com SVN.

Barry Wark