is a spotlight delegate necessary for batch indexing?

In this year's WWDC presentation it was suggested that a best practice for batching indexes was to use a spotlight delegate.


In my case, the data I have is static and will not change during the lifetime of the app. There are somewhere between 500 - 5000 total items to index. Is there a reason I should not just run a background thread to do the indexing rather than implement a delegate? I have a database variable to track if I've already indexed the data or not...


I have several apps that have this kind of data; I'm trying to abstract the spotlight function such that I don't have to add a delegate to each app. Of course, I could add the delegate to the abstraction, but I'm really just trying to understand if there is more advantages to using a delegate.

Accepted Reply

Running a background operation to do the indexing is fine, and sounds like a good plan and relying on the batch indexing sounds like it's right for you.


But you should still implement the delegate methods in the event that the OS needs you to re-index something. Even though the contents might not change during the lifetime of your app, the Spotlight index might need to be updated for various reasons and the delegate is the means that the OS can tell you that something needs to be re-indexed.


For best results you should also implement a spotlight extension so that if the OS needs to reindex something and your app isn't running it can fire up that extension and have it do the indexing work.

Replies

Running a background operation to do the indexing is fine, and sounds like a good plan and relying on the batch indexing sounds like it's right for you.


But you should still implement the delegate methods in the event that the OS needs you to re-index something. Even though the contents might not change during the lifetime of your app, the Spotlight index might need to be updated for various reasons and the delegate is the means that the OS can tell you that something needs to be re-indexed.


For best results you should also implement a spotlight extension so that if the OS needs to reindex something and your app isn't running it can fire up that extension and have it do the indexing work.

Does anyone know how to test the extension, yet? I can't find anything and it feels pretty blind to just release the extension and hope that it works. A way to trigger this in debug mode to confirm our code paths work would be really helpful.